可以选择官方提供的工具来选择最优路径: 首先安装npm registry的管理工具nrm:
➜ npm install -g nrm npm WARN deprecated coffee-script@1.7.1: CoffeeScript on NPM has moved to "coffeescript" (no hyphen) /usr/local/bin/nrm -> /usr/local/lib/node_modules/nrm/cli.js /usr/local/lib └── nrm@1.0.2
可以使用nrm来查看有哪些镜像:
➜ nrm ls * npm ---- https://registry.npmjs.org/ cnpm --- http://r.cnpmjs.org/ taobao - https://registry.npm.taobao.org/ nj ----- https://registry.nodejitsu.com/ rednpm - http://registry.mirror.cqupt.edu.cn/ npmMirror https://skimdb.npmjs.com/registry/ edunpm - http://registry.enpmjs.org/
然后使用nrm和镜像的别名就可以切换镜像的地址:
Registry has been set to: https://registry.npm.taobao.org/➜ nrm use taobao
其实nrm还给我们提供了测速工具来测试当前网络到所有镜像地址的访问耗时,我们可以结合测速结果选择更优的镜像地址:
➜ nrm test npm ---- 403ms cnpm --- 219ms * taobao - 350ms nj ----- Fetch Error rednpm - 115ms npmMirror 1169ms edunpm - 220ms
No comments:
Post a Comment