一、选择npm镜像源
- 官方源:https://registry.npmjs.org/
- CNPM镜像:https://cnpmjs.org/
- 淘宝NPM镜像: https://registry.npm.taobao.org/
二、设置NPM镜像节点
1、设置镜像节点(以淘宝镜像为例):
npm config set registry https://registry.npm.taobao.org/
2、检测镜像节点设置是否成功
npm config get registry
3、重置镜像节点
npm config delete registry
三、使用CNPM代替原官方NPM
npm install -g cnpm --registry=https://registry.npm.taobao.org
四、结尾
虽然我们有不得不使用NPM镜像的理由,但我认为一般情况下,仍然建议使用官方NPM。