簡(jiǎn)介:
Node 可以通過(guò)n來(lái)管理不同的版本。類似Python中的pyenv進(jìn)行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后輸出當(dāng)前已經(jīng)安裝的node版本以及正在使用的版本(前面有一個(gè)o),你可以通過(guò)移動(dòng)上下方向鍵來(lái)選擇要使用的版本逻住,最后按回車生效钟哥。
安裝最新的版本
$ n latest
安裝穩(wěn)定版本
$ n stable
刪除某個(gè)版本
n use 0.10.21 some.js
常見(jiàn)問(wèn)題和解決
- 使用國(guó)外源下載太慢:
n 8.2.1
install : node-v8.2.1
Error: invalid version 8.2.1
TODO:
擴(kuò)展閱讀
node升級(jí)神器-n
http://www.lovejavascript.com/#!zone/blog/content.html?id=68
簡(jiǎn)介:
在 n 的 github 上有這么一句:
Node.js version management: no subshells, no profile setup, no convoluted API, just simple.
node.js版本管理: 沒(méi)有分支層,沒(méi)有外形設(shè)置瞎访,沒(méi)有復(fù)雜的api腻贰,就是簡(jiǎn)單
系統(tǒng)兼容
支持mac 與 linux,兩個(gè)系統(tǒng)我都已安裝備扒秸。 根據(jù)作者提供信息播演,n不支持window
利用N來(lái)管理nodejs的版本問(wèn)題
http://blog.csdn.net/jiangbo_phd/article/details/51476155
簡(jiǎn)介:
n是Node的一個(gè)模塊,作者是TJ Holowaychuk(鼎鼎大名的Express框架作者)