• 获取当前使用的镜像源
npm config get registryhttps://registry.npmjs.org/
  • 使用指定的镜像源
npm config set registry https://registry.npm.taobao.org/
  • 使用 npm config 命令来更改镜像源太麻烦, 我们使用 nrm 来帮我们管理多个镜源
npm i nrm -gnrm -V1.2.1
  • nrm 展示当前可用源
nrm ls* npm -------- https://registry.npmjs.org/  yarn ------- https://registry.yarnpkg.com/  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 列出了当前可切换使用的源, 左边带星号的表示当前正在使用的源。

  • 使用列表中的源
nrm use njRegistry has been set to: https://registry.nodejitsu.com/
  • nrm 还可以用来测试镜像源的延迟
nrm test yarncnpm --- 208msnrm test taobaotaobao - 102ms