npm install安装一直卡在 node-sass安装失败

windows上安装 node-sass

参考 https://segmentfault.com/a/1190000021129447

各种百度都不行,cnpm也不想,几经周折,终于成功了,具体如下:

在项目内添加一个 .npmrc 文件:

  1. phantomjs_cdnurl=http://cnpmjs.org/downloads
  2. sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
  3. electron_mirror=https://npm.taobao.org/mirrors/electron/
  4. registry=https://registry.npm.taobao.org/

然后使用 npm install 安装 node-sass 和 phantomjs 时都能自动从淘宝源上下载,但是在使用npm publish的时候要把 registry 这一行给注释掉,否则就会发布到淘宝源上去了。

注:

  1、 .npmrc 文件打开,可以在WebStorm的当前工程目录下使用命令:  npm config edit

    2、找到所在目录,我的是C:\Users\Administrator 大家看自己安装的位置

 

以下是试用后无效方式~_~!!!(也可能是本人操作有问题无效的)

一、安装node-sass

npm i node-sass -s安装

二、代理设置null

  1. npm config set proxy null

  2. npm config set https-proxy null

  3. npm config set registry http://registry.cnpmjs.org/

三、代理设置为其他内容

npm install --global --production windows-build-tools

到时候会自动下载python的

如果timeout报错 请检查代理设置,按如下设置下吧

nmp config set proxy http://1.1.1.1

nmp config set https-proxy http://1.1.1.1

四、下载包安装

将 Node 降级到6.16

删除 node_modules 文件夹。
在 Terminal 运行 npm install --global windows-build-tools --save
再安装node-sass npm install node-sass@4.12.0 --save (或最新版本)
到这里,错误应该就已经解决了,收到了 gyp info ok 的提示!
如果遇到 Node Sass could not find a binding for your current environment,再运行 npm rebuild node-sass 就可以了

五、清缓存安装

npm cache clean --force

六、卸载重装(这样弄一下,我npm都有问题,只能重新安装node.js)

npm uninstall node-sass

npm install node-sass

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值