很多时候我们都会根据需要去切换源,但是淘宝镜像一般都会在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/
PS C:\Users\link\Desktop\WebSocket> nrm ls
npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
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/
PS C:\Users\link\Desktop\WebSocket> nrm use npm
Registry has been set to: https://registry.npmjs.org/
PS C:\Users\link\Desktop\WebSocket> nrm ls 查询npm
* npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
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/
PS C:\Users\link\Desktop\WebSocket> nrm use taobao
Registry has been set to: https://registry.npm.taobao.org/
代码块