目录
【已解决】1.1 安装gyp-解决gyp ERR! build error
【已解决】1.4 Error: Node Sass does not yet support your current environment
1 关于node-sass的各种问题+解决
使用别人的一个项目,估计2019年写的
npm install 没问题
npm run dev 启动项目,报错
Module build failed: Error: Cannot find module 'node-sass'
预处理步骤:
①采用网上解决方法:用阿里镜像cnpm安装,依旧失败
②项目路径中存在中文:修改中文地址为英文地址,依旧失败
③npm install node-sass@版本号,依旧失败
④错误代码里可以检索到 gyp ERR! build error
⑤同样的代码,MAC电脑正常使用,windows失败(甚至其他win电脑也可以使用)
感谢大佬支持
【已解决】1.1 安装gyp-解决gyp ERR! build error
主要是windows平台缺少编译环境
在webstrom里面不能用,用管理员身份打开cmd,运行即可
建议在项目文件目录下 用管理员身份打开powershell
① npm install -g node-gyp
② npm install --global --production windows-build-tools
③ 删除之前安装的文件
npm uninstall node-sass
④ 重新安装
npm install node-sass
【已解决】1.2 not found: python2
遇到一个很倒霉的事情,公司网络无法完成虚拟环境的配置,只要换成自己的无线就可以了
① 利用anconda创建python2的虚拟环境,并激活
conda create -n vuetest-py2.7 python=2.7 # 创建虚拟环境
activate vuetest-py2.7 # 激活环境(在项目中激活)
② 在项目中激活python2 的环境,然后安装:
npm install node-sass
【已解决】1.3 无法下载配置文件
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/win32-x64-72_binding.node
can not ……
换了好几个网络,挂了vpn,设置了各种代理,还是无法下载,最后小伙伴想了个招
① 先在指定网址下载配置文件(就是from http……那一大串地址)
② 找一台MAC电脑,下载项目并且正常使用,定位这个配置文件在哪个盘那个位置
⑤ 在自己电脑找到对应路径,把文件复制粘贴进去:
⑥ 先删除后重装
npm uninstall node-sass
npm install node-sass
npm run dev
【已解决】1.4 Error: Node Sass does not yet support your current environment
Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (93)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.1
版本不对,点开`https://github.com/sass/node-sass/releases/tag/v4.14.1`,就可以发现我们的node v16.5和node-sass v4.14.1不适配
一般是去匹配低版本的,因为兼容问题。所以把node降低一下版本就行了
PS: node和npm的版本注意适配 官方版本信息