node-sass

出现的问题: 切换各种node版本,node-sass出现下边问题

gyp ERR! cwd /Users/liuna/Desktop/关税宝/engine-web/node_modules/node-sass gyp ERR! node -v v14.21.3 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok Build failed with error code: 1 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.14.1 postinstall: node scripts/build.js``

解决办法:

  1. 卸载node-sass
js 复制代码
npm uninstall node-sass
rm -rf node_modules package-lock.json
  1. 安装 sass(兼容 node-sass API)
js 复制代码
npm install sass@1.32.13 --save-dev
  1. 重新安装依赖
js 复制代码
npm install

说明:

  • node-sass 已停止维护(官方在 2020 年后不再更新),且依赖 Python、Xcode 等编译环境,在现代系统(尤其是 M1/M2 Mac)上容易出现兼容性问题。
  • sass 是官方推荐的替代品,纯 JS 实现,无需任何编译工具,安装即能用,且与 node-sass 的 API 完全兼容(项目中 import 'node-sass' 可直接改为 import 'sass',若有使用的话)。
相关推荐
崔庆才丨静觅10 小时前
hCaptcha 验证码图像识别 API 对接教程
前端
passerby606111 小时前
完成前端时间处理的另一块版图
前端·github·web components
掘了11 小时前
「2025 年终总结」在所有失去的人中,我最怀念我自己
前端·后端·年终总结
崔庆才丨静觅11 小时前
实用免费的 Short URL 短链接 API 对接说明
前端
崔庆才丨静觅11 小时前
5分钟快速搭建 AI 平台并用它赚钱!
前端
崔庆才丨静觅12 小时前
比官方便宜一半以上!Midjourney API 申请及使用
前端
Moment12 小时前
富文本编辑器在 AI 时代为什么这么受欢迎
前端·javascript·后端
崔庆才丨静觅12 小时前
刷屏全网的“nano-banana”API接入指南!0.1元/张量产高清创意图,开发者必藏
前端
剪刀石头布啊12 小时前
jwt介绍
前端
爱敲代码的小鱼12 小时前
AJAX(异步交互的技术来实现从服务端中获取数据):
前端·javascript·ajax