转载自:http://yijiebuyi.com/blog/4ef268db0dcfd2a42ad138a1a054bf0b.html
之前写了一篇博文,关于如何把 npm 换到国内镜像员的博文,如下: 给电脑换 npm 国内镜像员 cnpm
为什么要换,你懂的!
今天给大家推荐一个 npm 开源包 nrm
基于 npm ,全局安装以后,你开源无缝快速切换几个源,提高下载速度,拒绝 loading !
安装
npm  install   -g   nrm  
开源地址
https://github.com/Pana/nrm
使用
查看帮助
 ➜  /Users/zhangzhi/code  >nrm -h  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    
查看当前支持切换的源
 ➜  /Users/zhangzhi/code  >nrm ls    npm ---- https://registry.npmjs.org/   cnpm --- http://r.cnpmjs.org/ * taobao - http://registry.npm.taobao.org/   edunpm - http://registry.enpmjs.org/   eu ----- http://registry.npmjs.eu/   au ----- http://registry.npmjs.org.au/   sl ----- http://npm.strongloop.com/   nj ----- https://registry.nodejitsu.com/   pt ----- http://registry.npmjs.pt/    
上面列出了可选的 9个源,还用 * 号标记出了当前我使用的源
切换指定的源
假如现在我想把 taobao 源 切换成 eu 的镜像源( 貌似走的教育网,我也不确定速度是不是快,只是演示切换)
➜  /Users/zhangzhi/code  >nrm use eu   Registry has been set to: http://registry.npmjs.eu/  
切换后的源列表
➜  /Users/zhangzhi/code  >nrm ls    npm ---- https://registry.npmjs.org/   cnpm --- http://r.cnpmjs.org/   taobao - http://registry.npm.taobao.org/   edunpm - http://registry.enpmjs.org/ * eu ----- http://registry.npmjs.eu/   au ----- http://registry.npmjs.org.au/   sl ----- http://npm.strongloop.com/   nj ----- https://registry.nodejitsu.com/   pt ----- http://registry.npmjs.pt/   
可以看到源已经切换成了 eu
你还可以添加已知的源,或者删除