直接切换
国外镜像会很慢
可用 get命令查看registry:
npm config get registry
初始地址为:
http://registry.npmjs.org
用set命令换成阿里的镜像就可以了:
npm config set registry https://registry.npm.taobao.org
再执行命令:
npm install
或者直接执行:
npm install --registry=https://registry.npm.taobao.org
使用nrm
可以使用nrm – NPM registry 管理工具
全局安装nrm:
npm install -g nrm
查看registry:
nrm ls //查看所有registry
* npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
eu ----- http://registry.npmjs.eu/
au ----- http://registry.npmjs.org.au/
sl ----- http://npm.strongloop.com/
nj ----- https://registry.nodejitsu.com/
nrm use cnpm //切换registry到cnpm地址
Registry has been set to: http://r.cnpmjs.org/