很多时候我们都会根据需要去切换源,但是淘宝镜像一般都会在install的时候出一些错误,此时就需要切源:
一: 淘宝镜像:
- 临时使用:
npm --registry https://registry.npm.taobao.org install express
- 持久使用:
npm config set registry https://registry.npm.taobao.org
- 使用cnpm:
npm install -g cnpm --registry https://registry.npm.taobao.org
二: 使用官方镜像:
npm config set registry https://registry.npmjs.org/
使用nrm -- NPM registry 管理工具
- Install
npm install -g nrm
- Example
$ nrm ls
* npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
from:https://www.jianshu.com/p/b2283aede1a0