Node版本管理控制器n

简介:

Node 可以通过n来管理不同的版本。类似Python中的pyenv进行python多版本管理。

安装 n:

$ npm install -g n

查看帮助:

$ n --help

  Usage: n [options/env] [COMMAND] [args]

  Environments:
    n [COMMAND] [args]            Uses default env (node)
    n io [COMMAND]                Sets env as io

  Commands:

    n                              Output versions installed
    n latest                       Install or activate the latest node release
    n -a x86 latest                As above but force 32 bit architecture
    n stable                       Install or activate the latest stable node release
    n <version>                    Install node <version>
    n use <version> [args ...]     Execute node <version> with [args ...]
    n bin <version>                Output bin path for <version>
    n rm <version ...>             Remove the given version(s)
    n --latest                     Output the latest node version available
    n --stable                     Output the latest stable node version available
    n ls                           Output the versions of node available

  (iojs):
    n io latest                    Install or activate the latest iojs release
    n io -a x86 latest             As above but force 32 bit architecture
    n io <version>                 Install iojs <version>
    n io use <version> [args ...]  Execute iojs <version> with [args ...]
    n io bin <version>             Output bin path for <version>
    n io rm <version ...>          Remove the given version(s)
    n io --latest                  Output the latest iojs version available
    n io ls                        Output the versions of iojs available

  Options:

    -V, --version   Output current version of n
    -h, --help      Display help information
    -q, --quiet     Disable curl output (if available)
    -d, --download  Download only
    -a, --arch      Override system architecture

  Aliases:

    which   bin
    use     as
    list    ls
    -       rm

# 查看可用的Node版本
$ n ls

    0.8.6
    0.8.7
    0.8.8
    0.8.9
    0.8.10
    0.8.11
    0.8.12
    0.8.13
    0.8.14
    0.8.15
    0.8.16
    0.8.17
    0.8.18
    0.8.19
    0.8.20
    0.8.21
    0.8.22
    0.8.23
    0.8.24
    0.8.25
    0.8.26
    0.8.27
    0.8.28

安装不同的版本:

$n 6.0.0

     install : node-v6.0.0
       mkdir : /usr/local/n/versions/node/6.0.0
       fetch : https://nodejs.org/dist/v6.0.0/node-v6.0.0-darwin-x64.tar.gz
   installed : v6.0.0

$ node --version
v6.0.0

查看已安装的版本:

$ n
    node/0.10.34
    node/5.9.1
  ο node/6.0.0

还可以选择不同的版本
安装完成之后,直接输入n后输出当前已经安装的node版本以及正在使用的版本(前面有一个o),你可以通过移动上下方向键来选择要使用的版本,最后按回车生效。

安装最新的版本
$ n latest
安装稳定版本
$ n stable
删除某个版本
$ n rm 0.10.1
以指定的版本来执行脚本
$ n use 0.10.21 some.js
常见问题和解决
======

  1. 使用国外源下载太慢:
n 8.2.1

     install : node-v8.2.1

  Error: invalid version 8.2.1

TODO:

扩展阅读

node升级神器-n
http://www.lovejavascript.com/#!zone/blog/content.html?id=68
简介:
在 n 的 github 上有这么一句:
Node.js version management: no subshells, no profile setup, no convoluted API, just simple.
node.js版本管理: 没有分支层,没有外形设置,没有复杂的api,就是简单

系统兼容
支持mac 与 linux,两个系统我都已安装备。 根据作者提供信息,n不支持window

利用N来管理nodejs的版本问题
http://blog.csdn.net/jiangbo_phd/article/details/51476155
简介:
n是Node的一个模块,作者是TJ Holowaychuk(鼎鼎大名的Express框架作者)



作者:jiaxiaolei
链接:https://www.jianshu.com/p/a927bcecdbc0
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值