说明:安装Node 时默认下载地址是http://registry.npmjs.org
解决方案
1.在 .npmrc 上配置一个国内的 registry 镜像
2.使用 cnpm
3.使用 VPN
第1个方案很粗暴,可以解决很多下载慢的问题,但是当你用 npm publish 时就会失败
第2个方案不错,但这样你就又会遇到问题,到底哪些命令需要用 cnpm,哪些命令需要用 npm 呢?
VPN 方案有时也不能百分百解决问题,有时有些 VPN 也不稳定,但有个 VPN 很保险就是
推荐方案:使用smart-npm
(可以在我们使用 npm install 时自动从国内的镜像下载,而在我们使用 npm publish 又能发布到官方的 registry 上)
安装
npm install --global smart-npm --registry=https://registry.npm.taobao.org/
这个命令不行可以使用下面这两个
npm instal