我对stylePreprocessorOptions的includePath有问题,无论我做什么都行不通。
我已经看到github上有已解决的票证,但是我用尽了所有选项,任何想法都可能会有所帮助:-)。我发现的任何来源都建议添加我已经添加的选项。
Error message:
ERROR in ./src/app/app.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
@import 'variables';
^
File to import not found or unreadable: variables.
in /home/rdeutz/projects/rbt/checkout-system-v3/src/app/app.component.scss (line 1, column 1)
Error:
@import 'variables';
这是我的配置:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"my1": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist-my1",
"index": "src/index-my1.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"stylePreprocessorOptions": {
"includePaths": [
"src/my1"
]
},
....
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"src/styles.scss",
"node_modules/font-awesome/css/font-awesome.css"
],
"assets": [
"src/assets",
"src/my1/favicon.ico"
],
"stylePreprocessorOptions": {
"includePaths": [
"src/my1"
]
}
}
},
一切都很适合构建,但是测试无法正常工作。
Versions:
Angular CLI: 7.2.3
Node: 10.15.0
OS: linux x64
Angular: 7.2.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.3
@angular-devkit/build-angular 0.12.3
@angular-devkit/build-optimizer 0.12.3
@angular-devkit/build-webpack 0.12.3
@angular-devkit/core 7.2.3
@angular-devkit/schematics 7.2.3
@angular/cli 7.2.3
@ngtools/webpack 7.2.3
@schematics/angular 7.2.3
@schematics/update 0.12.3
rxjs 6.3.3
typescript 3.2.4
webpack 4.28.4
npm --version -> 6.4.1
谢谢!
答案 0 :(得分:0)
或多或少是愚蠢的错误。配置了两个项目,它针对一个项目运行,而对于另一个项目则不运行。因此,该错误来自第二次运行,并且第二次运行已正确配置。