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

14,035次阅读
没有评论

共计 1079 个字符,预计需要花费 3 分钟才能阅读完成。

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

> node-sass@5.0.0 install E:projectDMSWebnode_modulesnode-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:projectDMSWebnode_modulesnode-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 镜像

 

 


关注作者公众号,订阅推送更多及时的前端资讯、学习资料

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

    正文完
     0
    Yojack
    版权声明:本篇文章由 Yojack 于1970-01-01发表,共计1079字。
    转载说明:
    1 本网站名称:优杰开发笔记
    2 本站永久网址:https://yojack.cn
    3 本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行删除处理。
    4 本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
    5 本站所有内容均可转载及分享, 但请注明出处
    6 我们始终尊重原创作者的版权,所有文章在发布时,均尽可能注明出处与作者。
    7 站长邮箱:laylwenl@gmail.com
    评论(没有评论)