写在前面: npm 配置
作者:请叫我足下
链接:https://www.jianshu.com/p/a2dc9400ff56
- 首先安装 npm
sudo apt install npm
- 查看npm源地址
$ sudo npm config ls -l | grep registry
结果:
registry = "https://registry.npmjs.org/"
- 使用淘宝的npm源全局安装nrm包;
$ sudo npm i nrm -g --registry=https://registry.npm.taobao.org/
使用nrm ls查看当前所有可用的镜像源地址以及当前所使用的镜像源地址,*号标记的就是当前使用的npm源;
$ 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 use npm
或nrm use taobao
切换不同的镜像源地址,例如你想切换npm源到npm官方源;
$ nrm use npm
Registry has been set to: https://registry.npmjs.org/
$ 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/
# 更新 npm 版本可执行如下命令
$ sudo npm i npm -g
网友评论