windows上安装 node-sass
参考 https://segmentfault.com/a/1190000021129447
各种百度都不行,cnpm也不想,几经周折,终于成功了,具体如下:
在项目内添加一个 .npmrc
文件:
phantomjs_cdnurl=http://cnpmjs.org/downloads
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
- electron_mirror=https://npm.taobao.org/mirrors/electron/
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
-
npm config set proxy null
-
npm config set https-proxy null
-
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