npm安装、切换淘宝镜像

npm默认镜像源是国外的,安装依赖速度较慢,使用国内的镜像源速度会快一些。

1、设置淘宝镜像源:

npm config set registry https://registry.npmmirror.com/

2、查看当前镜像源:

npm config get registry

3、设置官方镜像源:

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

还可以使用nrm查看和切换镜像

//安装nrm,一定要全局安装
npm install -g nrm
//nrm查看所有镜像源命令,带*即为当前使用的源
nrm ls
  npm ---------- https://registry.npmjs.org/
  yarn --------- https://registry.yarnpkg.com/
  tencent ------ https://mirrors.cloud.tencent.com/npm/
  cnpm --------- https://r.cnpmjs.org/
* taobao ------- https://registry.npmmirror.com/
  npmMirror ---- https://skimdb.npmjs.com/registry/

//如果使用nrm ls发现全面都没有带*,则可以参考最后面的教程

//切换镜像源命令
nrm use xxx  //例:nrm use taobao 就可以切换自己想用的镜像源了

//当前使用的源
nrm current
taobao

关于nrm ls没有*的问题解决:

①、找到本地全局包安装目录下的nrm包,修改该目录下的cli.js文件。

 ②、将&&修改为||,然后运行一下 nrm use taobao,之后执行nrm ls就可以了。

if (hasOwnProperty(customRegistries, name) || (name in registries || customRegistries[name].registry === registry.registry)) {
    registry[FIELD_IS_CURRENT] = true;
    customRegistries[name] = registry;
}

 

  • 5
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值