【已解决】 ‘node-sass‘ 针对wins缺少编译环境+无法下载

目录

1 关于node-sass的各种问题+解决

【已解决】1.1 安装gyp-解决gyp ERR! build error

【已解决】1.2 not found: python2

【已解决】1.3 无法下载配置文件

【已解决】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的版本注意适配  官方版本信息

参考

node-sass 安装失败的各种坑

解决Cannot find module 'node-sass'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值