Node,Npm版本管理工具
node版本管理工具nvm
安装
Mac 通过curl 或者wget工具安装
GitHub:https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
Win 找到对应的 .exe 文件 下载安装
使用
执行命令nvm ls
查看可选的源。
20.9.0
18.18.2
* 16.20.2 (Currently using 64-bit executable)
14.21.3
12.18.3
*****表示当前正在使用的node版本
切换
nvm use <版本号>
查看当前可以下载的版本
nvm list available
| CURRENT | LTS | OLD STABLE | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
| 21.2.0 | 20.10.0 | 0.12.18 | 0.11.16 |
| 21.1.0 | 20.9.0 | 0.12.17 | 0.11.15 |
| 21.0.0 | 18.18.2 | 0.12.16 | 0.11.14 |
| 20.8.1 | 18.18.1 | 0.12.15 | 0.11.13 |
| 20.8.0 | 18.18.0 | 0.12.14 | 0.11.12 |
| 20.7.0 | 18.17.1 | 0.12.13 | 0.11.11 |
| 20.6.1 | 18.17.0 | 0.12.12 | 0.11.10 |
| 20.6.0 | 18.16.1 | 0.12.11 | 0.11.9 |
| 20.5.1 | 18.16.0 | 0.12.10 | 0.11.8 |
| 20.5.0 | 18.15.0 | 0.12.9 | 0.11.7 |
| 20.4.0 | 18.14.2 | 0.12.8 | 0.11.6 |
| 20.3.1 | 18.14.1 | 0.12.7 | 0.11.5 |
| 20.3.0 | 18.14.0 | 0.12.6 | 0.11.4 |
| 20.2.0 | 18.13.0 | 0.12.5 | 0.11.3 |
| 20.1.0 | 18.12.1 | 0.12.4 | 0.11.2 |
| 20.0.0 | 18.12.0 | 0.12.3 | 0.11.1 |
| 19.9.0 | 16.20.2 | 0.12.2 | 0.11.0 |
| 19.8.1 | 16.20.1 | 0.12.1 | 0.9.12 |
| 19.8.0 | 16.20.0 | 0.12.0 | 0.9.11 |
| 19.7.0 | 16.19.1 | 0.10.48 | 0.9.10 |
下载
下载指定版本
nvm install <node 版本号>
下载最新版本
nvm install latest
21.2.0
Downloading node.js version 21.2.0 (64-bit)...
使用
nvm use <node 版本号>
eg: 使用大版本为14的node版本
nvm use 14
删除
nvm uninstall <node 版本号>
eg: 删除版本为14的node版本
npm版本管理工具nrm
npm -v
安装
npm install -g nrm
使用
执行命令nrm ls查看可选的源。
*npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
taobao - http://registry.npm.taobao.org/
eu ----- http://registry.npmjs.eu/
au ----- http://registry.npmjs.org.au/
sl ----- http://npm.strongloop.com/
nj ----- https://registry.nodejitsu.com/
其中,带*
的是当前使用的源,上面的输出表明当前源是官方源。****
- 切换
如果要切换到taobao
源,执行命令 nrm use taobao
。
- 增加
你可以增加定制的源,特别适用于添加企业内部的私有源,执行命令 nrm add <registry> <url>
,其中reigstry
为源名,url
为源的路径。
nrm add registry http://registry.npm.frp.trmap.cn/
- 删除
执行命令nrm del <registry>
删除对应的源。
- 测试速度
你还可以通过 nrm test
测试相应源的响应时间。
nrm test npm