默认源
在终端下运行以下命令可查看默认源,如果没有修改过的话,一般是 https://registry.npmjs.org/
npm 可以修改默认源地址,比如修改为我们常用的淘宝源:
1
| npm config set registry https://registry.npm.taobao.org/
|
但是如果有几个源要进行切换的话,这种方法就显得太麻烦了。
Nrm
就是专门用于解决这个问题,它可以帮助你简单、快速的在不同的 npm registry(源)之间进行切换。
安装 nrm
使用
可用源列表
输入命令 nrm ls
可查看源列表
1 2 3 4 5 6 7 8 9
| nrm ls
* npm -------- https: yarn ------- https: cnpm ------- http: taobao ----- https: nj --------- https: npmMirror -- https: edunpm ----- http:
|
说明
- *标识说明它是当前使用的 registry(源)
- npm 是 registry(源)名字,可以在 nrm 里用于切换的名字
- 当前版本 nrm 共提供了 7 个registry(源)
测速
为了确定哪个registry(源)下载速度更快,我们需要进行测速,通过测速结果,来决定具体使用哪个registry(源)
切换源
输入命令 nrm use <registry name>
可切换对应源,如:
增加源
删除源