通常使用下面的方式为 NPM 设置镜像:
npm config set registry https://registry.npmmirror.com
用下面的命令可以恢复镜像为官方镜像:
npm config set registry https://registry.npmjs.org
如果要查看当前使用的镜像:
npm config get registry
NRM
更推荐的方式是使用 nrm 工具管理 NPM 镜像,这个工具同样使用 NPM 安装:
sudo npm install -g nrm
因为要使用
-g
全局安装,所以这里要使用sudo
用 root 权限安装,否则可能报错。
查看 nrm 支持的镜像列表:
nrm ls
切换镜像为淘宝镜像:
nrm use taobao
测试当前镜像速度:
nrm test
The End.
文章评论