在墙内久了,不免会碰到撞墙的时候,所幸国内也有众多 NPM 镜像可供选择,在大多数状况下咱们能够使用国内的源(好比 淘宝 NPM 镜像)去替换官方的源以加快下载包的速度。不过呢,咱们在发布本身的包的时候却须要将源修改回官方的 https://registry.npmjs.org/ 源。
修改源地址为淘宝 NPM 镜像node
npm config set registry http://registry.npm.taobao.org/
修改源地址为官方源git
npm config set registry https://registry.npmjs.org/
使用nrm
来切换源github
npm install -g nrm
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 taobao
Registry has been set to: https://registry.npm.taobao.org/
更多请参考官方文档
nrm githubnpm
推荐升级方法code
参考官方升级方法文档
npm官网连接get
npm install npm@latest -g