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',若有使用的话)。
相关推荐
万少2 小时前
HarmonyOS 开发必会 5 种 Builder 详解
前端·harmonyos
橙序员小站4 小时前
Agent Skill 是什么?一文讲透 Agent Skill 的设计与实现
前端·后端
炫饭第一名7 小时前
速通Canvas指北🦮——基础入门篇
前端·javascript·程序员
王晓枫7 小时前
flutter接入三方库运行报错:Error running pod install
前端·flutter
符方昊7 小时前
React 19 对比 React 16 新特性解析
前端·react.js
ssshooter7 小时前
又被 Safari 差异坑了:textContent 拿到的值居然没换行?
前端
曲折7 小时前
Cesium-气象要素PNG色斑图叠加
前端·cesium
Forever7_8 小时前
Electron 淘汰!新的桌面端框架 更强大、更轻量化
前端·vue.js
Angelial8 小时前
Vue3 嵌套路由 KeepAlive:动态缓存与反向配置方案
前端·vue.js
jiayu8 小时前
Angular学习笔记24:Angular 响应式表单 FormArray 与 FormGroup 相互嵌套
前端