npm使用淘宝镜像

淘宝 npm 地址: http://npm.taobao.org/

如何使用 
有很多方法来配置npm的registry地址,下面根据不同情境列出几种比较常用的方法。以淘宝npm镜像举例:

1.临时使用

npm --registry https://registry.npm.taobao.org install express

2.持久使用

npm config set registry https://registry.npm.taobao.org
  • 配置后可通过下面方式来验证是否成功 
    npm config get registry
  • 或 
    npm info express

3.通过cnpm使用

npm install -g cnpm --registry=https://registry.npm.taobao.org
  • 使用 
    cnpm install express

-------------------切换源-------------------

有时候,使用第三方镜像地址可能会出现莫名奇妙的问题,怎么办?

安装源管理工具nrm
npm install -g nrm

查看当前已配置好的所有源地址列表
nrm ls

切换为源(这里我切换为默认的源地址)
nrm use npm


其它
nrm add添加源
nrm del删除源
nrm test测试源的响应时间,可以作为使用哪个源的参考

 
参考
http://www.jianshu.com/p/5dd18d246281
http://www.cnblogs.com/YMaster/p/6810339.html

原文地址:https://www.cnblogs.com/dshvv/p/7634470.html