方案一(推荐):使用淘宝镜像仓库作为npm仓库
- 配置淘宝源
npm config set registry https://registry.npm.taobao.org
- 验证是否成功
npm config get registry
当显示如下,说明设置成功
- 使用,以express为例
npm install express
方案二(不推荐):使用cnpm命令
- 全局安装cpnm
npm install -g cnpm --registry=https://registry.npm.taobao.org
- 使用,以express为例
cnpm install express