当我们使用npm下载包时,这个下载速度很是个问题,近来发现nrm这个包,专门用来管理源的,很是方便,特分享出来
安装nrm
npm i -g nrm
查看可使用的源
nrm ls
会出现下面可使用的源
其中,带*的是当前使用的源,上面的输出表明当前源是官方源
➜ ~ nrm ls
* npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
➜ ~
切换源
nrm use cnpm
出现下面代码,重新查询,可看到已切换到cnpm源
➜ ~ nrm use cnpm
verb config Skipping project config: /home/seebin/.npmrc. (matches userconfig)
Registry has been set to: http://r.cnpmjs.org/
➜ ~ nrm ls
npm ---- https://registry.npmjs.org/
* cnpm --- http://r.cnpmjs.org/
taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
➜ ~
测试源的速度
nrm test npm
可看到源的速度
➜ ~ nrm test npm
npm ---- 821ms
➜ ~ nrm test cnpm
* cnpm --- 433ms
➜ ~ nrm test taobao
taobao - 225ms
➜ ~