npm太慢,配置国内淘宝源
今天在npm install前端代码时,下载速度非常慢,要下载的东西下载不下来。
1  | Downloading binary from https://github.com/sass/node-sass/releases/download/v4.7.2/darwin-x64-64_bin  | 
还遇到如下错误:
1  | ERROR in ./~/css-loader?sourceMap!./~/resolve-url-loader?sourceMap!./~/sass-loader?sourceMap!./src/directives/plan-task/index.scss  | 
所以得考虑把npm的源换到国内,换成淘宝的镜像,命令如下:
1  | npm config set registry https://registry.npm.taobao.org  | 
设置成功后,可以查看目前系统使用的源
1  | npm config get registry  | 
像之前遇到的问题Cannot find module ‘node-sass’,我们可以再次执行npm install node-sass安装。
如果不想使用淘宝源了,可以还原回去。
1  | npm config delete registry  | 
或者
1  | npm config edit  | 
找到淘宝那两行,删除即可。