轉載自: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
你還可以添加已知的源,或者刪除