nrm切换npm源

快速切换npm公共源和自定义源

主页#

https://github.com/Pana/nrm

安装#

npm install -g nrm

使用#

列出可选的源#

nrm ls

# 输出
* npm ---- https://registry.npmjs.org/
  yarn --------- https://registry.yarnpkg.com/
  tencent ------ https://mirrors.cloud.tencent.com/npm/
  cnpm --------- https://r.cnpmjs.org/
  taobao ------- https://registry.npmmirror.com/
  npmMirror ---- https://skimdb.npmjs.com/registry/

* 的是当前使用的源,上面的输出表明当前源是官方源。

切换源#

nrm use cnpm
# 输出
 SUCCESS  The registry has been changed to 'cnpm'.

增加源#

nrm add  <registry> <url> [home]

删除源#

nrm del <registry>

测速#

nrm test npm
# 输出
  npm ---- 891 ms
  
# 全部测速
nrm test
# 输出
  npm ---------- 742 ms
  yarn --------- 725 ms
  tencent ------ 707 ms
* cnpm --------- 1234 ms
  taobao ------- 136 ms
  npmMirror ---- timeout (Fetch timeout over 5000 ms)