【发布时间】:2020-03-29 22:37:13
【问题描述】:
我正在使用 AngularCLI 和 Angular v8。 关于 Angular Universal,我遇到了一个问题,在我运行这些命令后,这些命令是设置的准备步骤:
ng generate universal --clientProject <project_name>
npm install @nguniversal/module-map-ngfactory-loader
npm install @nguniversal/express-engine
Add ModuleMapLoaderModule on AppServerModule
或
ng add @nguniversal/express-engine --clientProject <project_name>
npm run build:ssr && npm run serve:ssr
当我运行ng build --configuration staging 甚至ng build --prod 时,构建成功且没有错误。
但是当我运行ng run app:server:staging 或ng run app:server:production 时,我会遇到如下错误:
ERROR in Module build failed (from ./node_modules/sass-loader/lib/loader.js):
@import 'base/colors';
Can't find stylesheet to import.
....
我的angular.json 具有以下 SCSS 配置:
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
...
"stylePreprocessorOptions": {
"includePaths": [
"src/",
"src/assets/styles",
"node_modules"
]
},
想问一下我是否遗漏了什么或者是否有什么需要改变的?
已尝试重新安装或运行这些命令,但仍然没有成功:
rm -rf node_modules
rm package-lock.json
npm install
npm install node-sass
安装node-sass时,从"Can't find stylesheet to import."错误信息,现在是"File to import not found or unreadable: base/colors."
【问题讨论】:
-
面临与 scss 引用“找不到要导入的样式表”相同的问题...如果您找到任何解决方案,请分享。