You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular 14升级至15后出现SassError:主题映射非有效CSS值

Angular 14升级到15后SassError问题

将项目从Angular v14升级到Angular v15并执行npm install后,触发SassError:提示(background-color: rgba(22, 15, 15, 0), color: rgba(255, 255, 255, 0.9))不是有效的CSS值,错误出现在调用xm-register-theme($theme, basic)时。

测试验证:当$theme设为null时项目可正常运行,设为空映射()或样式映射时均报错。已尝试删除node_modules、package-lock.json重新安装依赖、清理Angular缓存等操作,问题仍未解决。

错误日志片段

./playground/styles.scss - 错误:模块构建失败(来自./node_modules/sass-loader/dist/cjs.js):
SassError:(background-color: rgba(22, 15, 15, 0), color: rgba(255, 255, 255, 0.9))不是有效的CSS值。
   ╷
17 │ $themes: xm-register-theme($theme, basic);
   │                            ^^^^^^
   ╵
  framework/src/theme/styles/_themes.scss 17:28  @forward
  framework/src/theme/styles/_all.scss 2:1       @forward
  playground/styles.scss 3:1                     root stylesheet

已尝试的修复命令

rm -rf node_modules
rm -rf package-lock.json
npm install -g @angular/cli@15.2.8
npm install --save-dev @angular/cli@15.2.8
npm install
ng cache clean && ng serve --port 7000

测试代码

// $theme: null; // 正常运行
// $theme: (); // 运行失败
$theme: (background-color: rgba(22, 15, 15, 0), color: rgba(255, 255, 255, 0.9));  // 运行失败
$themes: xm-register-theme($theme, basic);

内容的提问来源于stack exchange,提问作者CabinWJ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 09:57:56