npm 换源

由于npm的源在国外,所以有时候使用起来,会碰到速度极慢的情况,好在一些公司做了源的同步,可以使用这些源来达到加速下载,减少等待时间。

换源

  • 临时使用
npm --registry https://registry.npm.taobao.org install express --save
  • 持久使用
npm config set registry https://registry.npm.taobao.org
  • 验证
npm config get registry
  • 官方源
npm config set registry https://registry.npmjs.org/

通过 nrm 更换源

最近在工作的时候,发现淘宝的源,无法正常下载,于是需要换其他的源,在网上找源的过程中,发现了nrm -- NPM registry manager,它可以帮你快速的帮你在不同的源之间切换,现在包括npmcnpmtaobaonj(nodejitsu)rednpm,还可以加入你自己的私有源。

  • 安装
npm install -g 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
  skimdb -- https://skimdb.npmjs.com/registry
# 使用
$ nrm use cnpm  #switch registry to cnpm Registry has been set to: http://r.cnpmjs.org/

通过nrm换源,体验一下就提升了很多,工作更有效率了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 说到换源先说下什么是换源,为什么要换源。 一般对于一个软件有很多不同资源,不同的资源下载的速度有很大差异,就像在迅...
    keenjaan阅读 11,037评论 0 3
  • npm install express --registry=https://registry.npm.taoba...
    圣手小青龙阅读 157,164评论 6 66
  • 临时换源 npm --registry https://registry.npm.taobao.org insta...
    luichooy阅读 3,836评论 0 1
  • 一、使用淘宝镜像1.临时使用npm --registry https://registry.npm.taobao....
    nickfox阅读 110,803评论 7 18
  • npm config set registry https://registry.npm.taobao.org /...
    小沫360阅读 14,698评论 0 2