工具 · npm使用

切换下载安装包的仓库

直接使用npm命令切换

1.设置使用淘宝镜像

npm config set registry  + 需要切换的仓库地址
npm config set registry https://registry.npm.taobao.org

2.查看当前资源,看是否切换成功,成功后可直接使用cnpm命令

npm config get registry

3.还原到npm仓库

npm config set registry https://registry.npmjs.org

使用nrm快捷切换npm默认仓库

1.安装nrm

npm i -g nrm

列出所有npm源

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/

2.切到npm

nrm use npm

Registry has been set to: https://registry.npmjs.org/

3.测试所有仓库响应的时间

nrm test
* npm ---- 1130ms
  yarn --- 2339ms
  cnpm --- 1986ms
  taobao - 704ms
  nj ----- Fetch Error
  npmMirror  9314ms
  edunpm - Fetch Error
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值