NPM镜像管理
此文列出常见npm命令,大家共勉。
1.查看npm源地址
npm config list
1
结果:
metrics-registry = "http://registry.npm.taobao.org/"
1
2.修改registry地址,比如修改为淘宝镜像源。
npm set registry https://registry.npm.taobao.org/
1
如果有一天你肉身FQ到国外,用不上了,用rm命令删掉它
npm config rm registry
1
3.nrm 是专门用来管理和快速切换私人配置的 registry
建议全局安装
npm install nrm -g --save
1
用nrm ls
命令查看默认配置,带*号即为当前使用的配置
nrm ls
1
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/
1
2
3
4
5
6
7
2
3
4
5
6
7
也可以直接输入以下命令查看当前使用的是哪个源
nrm current
1
切换源
nrm use cnpm
1
用nrm add 命令添加公司私有npm源,如http://registry.npm.360.org(,起个别名叫qihoo
nrm add qihoo http://registry.npm.360.org
1
测试下速度
nrm test npm
1
输出
npm ---- 790ms
1
最后,如果你被公司开除了,怒删公司npm源配置
nrm del qihoo
1
4.更新Node
版本和npm
版本
清除node的cache(清除node的缓存,这个看情况而定,不是必须的)
sudo npm cache clean -f
1
安装"n"版本管理工具,管理node(没有错,就是n)
sudo npm install -g n
1
更新node版本
sudo npm install npm@latest -g
1
再查一遍本机当前Node和npm的版本吧
node -v
npm -v
1
2
2
上次更新: 2022/05/07, 16:05:00