npm镜像源管理

查看使用镜像

G:\ccri-law-backend-management>npm config get registry
https://registry.npmjs.org/

切换镜像

G:\ccri-law-backend-management>npm config set registry https://registry.npm.taobao.org

此文列出常见npm命令,大家共勉。
1、查看npm源地址
npm config list

结果:
metrics-registry = "http://registry.npm.taobao.org/"

2、修改registry地址,比如修改为淘宝镜像源。
npm set registry https://registry.npm.taobao.org/
如果有一天你肉身FQ到国外,用不上了,用rm命令删掉它
npm config rm registry

3、nrm是专门用来管理和快速切换私人配置的registry
建议全局安装
npm install nrm -g --save
用nrm ls命令查看默认配置,带*号即为当前使用的配置
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 current
切换源
nrm use cnpm
用nrm add 命令添加公司私有npm源,如http://registry.npm.360.org(随便写的),起个别名叫qihoo
nrm add qihoo http://registry.npm.360.org

测试下速度
nrm test npm
输出npm ---- 790ms

最后,如果你被公司开除了,怒删公司npm源配置
nrm del qihoo

4、更新Node版本和npm版本

清除node的cache(清除node的缓存,这个看情况而定,不是必须的)

sudo npm cache clean -f 

安装"n"版本管理工具,管理node(没有错,就是n)

sudo npm install -g n 

更新node版本

sudo npm install npm@latest -g 

再查一遍本机当前Node和npm的版本吧

node -v 
npm -v 

参考: https://www.cnblogs.com/wangmeijian/p/7072053.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值