在使用node中偶爾要切換版本感凤,使用n的某些功能都要去查一下,很厭煩粒督,遂自己總結(jié)一下 n 的安裝和使用
全局安裝 n
sudo npm install -g n
安裝最新穩(wěn)定版 node
sudo n stable
安裝最新版本 node
sudo n latest
刪除某個(gè)版本
n rm 10.13.0
使用 n 切換版本
n --回車(chē)
node/10.13.0
ο node/10.15.3
node/11.0.0
node/11.8.0
node/12.2.0
# 按上下鍵選擇版本后陪竿,回車(chē)
查看node版本
node -v
以指定的版本來(lái)執(zhí)行腳本
n use 10.13.0 test.js
其他有關(guān) n 的命令
查看幫助
n help
Usage: n [options/env] [COMMAND] [args]
Environments:
n [COMMAND] [args] Uses default env (node)
n project [COMMAND] Uses custom env-variables to use non-official sources
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 lts Install or activate the latest LTS 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 prune Remove all versions except the active version
n --latest Output the latest node version available
n --lts Output the latest LTS node version available
n ls Output the versions of node available
n uninstall Remove the installed node and npm
Options:
-V, --version Output 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
stable lts