nrm切换npm源利器

在使用npm时,官方的源下载npm包会比较慢,国内我们基本使用淘宝的源,最近公司内部搭建了一套npm私有仓库。要添加自己公司内部的npm源,公司内部的源不可能把npm官方的npm包都全量同步,故需要npm源之间的切换,如果使用npm registry xxx的话,太不好管理了。nrm是管理npm源切换的利器。使用方法如下:

安装nrm

1
npm install -g nrm

nrm --help 帮助命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Usage: nrm [options] [command]
Commands:
ls list all the registries
current show current registry name
use <registry> change registry to registry
add <registry> <url> [home] add one custom registry
del|rm <registry> delete one custom registry
home <registry> [browser] open the homepage of registry with optional browser
test [registry] show response time for specific or all registries
help print this help
Options:
-h, --help output usage information
-V, --version output the version number

nrm ls是列出来现在已经配置好的所有的原地址

1
2
3
4
5
6
npm ---- https://registry.npmjs.org/
* cnpm --- http://r.cnpmjs.org/
taobao - http://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
rednpm - http://registry.mirror.cqupt.edu.cn
npmMirror https://skimdb.npmjs.com/registry

nrm use npm

nrm add 添加源

nrm del 删除源

nrm test 测试源的响应时间,可以作为使用哪个源的参考