我正在我的一个Angular项目中使用@swimlane/ngx-datatable
,当我在本地系统上执行ng build --configuration=myconfig
时,它没有任何错误地构建,甚至通过执行ng serve
运行得很好。
问题是,当我尝试在Github Actions上运行相同的命令时,它失败了,并出现以下错误:
./src/styles.scss - Error: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
13 │ @import '~@swimlane/ngx-datatable/themes/bootstrap.scss';
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src/styles.scss 13:9 root stylesheet
at processResult (/home/runners/actions-runner/_work/ui/ui/node_modules/webpack/lib/NormalModule.js:713:19)
at /home/runners/actions-runner/_work/ui/ui/node_modules/webpack/lib/NormalModule.js:819:5
at /home/runners/actions-runner/_work/ui/ui/node_modules/loader-runner/lib/LoaderRunner.js:400:11
at /home/runners/actions-runner/_work/ui/ui/node_modules/loader-runner/lib/LoaderRunner.js:252:18
at context.callback (/home/runners/actions-runner/_work/ui/ui/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
at Object.callback (/home/runners/actions-runner/_work/ui/ui/node_modules/sass-loader/dist/index.js:54:7)
at Worker.<anonymous> (/home/runners/actions-runner/_work/ui/ui/node_modules/@angular-devkit/build-angular/src/sass/sass-service.js:134:25)
at Worker.emit (node:events:513:28)
at MessagePort.<anonymous> (node:internal/worker:236:53)
at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:736:20)
Error: Process completed with exit code 1.
我已经在我的styles.scss
文件中导入了datatable的所有scss文件,如下所示:
@import '~@swimlane/ngx-datatable/index.css';
@import '~@swimlane/ngx-datatable/themes/bootstrap.scss';
@import '~@swimlane/ngx-datatable/themes/material.scss';
@import '~@swimlane/ngx-datatable/themes/dark.scss';
@import '~@swimlane/ngx-datatable/assets/icons.css';
以下是我的Angular 配置:
"@swimlane/ngx-datatable": "^20.0.0",
---
---
"@angular-devkit/build-angular": "~12.2.7",
"@angular/cli": "~12.2.7",
"@angular/compiler-cli": "~12.2.0",
---
---
node version: 16.17.1
而且我可以在我的本地机器的node_modules中看到scss文件的路径。我该如何解决这个问题呢?提前感谢。:)
1条答案
按热度按时间68bkxrlz1#
引导程序css是否包含在angular.json中?它应该看起来像这样:
虽然这并不能真正解释为什么构建过程没有在本地失败。你确定你正在运行完全相同的命令吗?