解决npm安装node-sass失败的问题

执行 npm install 的时候出现node-sass模块无法下载的情况,看地址它是从github 拉取的

> node-sass@5.0.0 install E:\project\DMSWeb\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v5.0.0/win32-x64-83_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v5.0.0/win32-x64-83_binding.node": 

connect ETIMEDOUT 52.74.223.119:443

Timed out whilst downloading the prebuilt binary

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g. 

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> node-sass@5.0.0 postinstall E:\project\DMSWeb\node_modules\node-sass
> node scripts/build.js

全局切换npm源也不行,试了以下命令解决了

npm install --save node-sass --registry=https://registry.npm.taobao.org 
--disturl=https://npm.taobao.org/dist --sass-binary-site=http://npm.taobao.org/mirrors/node-sass

参数解释

  • --registry=https://registry.npm.taobao.org 淘宝npm包镜像
  • --disturl=https://npm.taobao.org/dist 淘宝node源码镜像,一些二进制包编译时用
  • --sass-binary-site=http://npm.taobao.org/mirrors/node-sass 这个才是node-sass镜像

 

评论

还没有评论...留下你的评论!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar