Angular 7 CLI生成的项目抛出"multi./src/styles.sass中的错误". [英] Angular 7 CLI generated project throws "ERROR in multi ./src/styles.sass"
问题描述
我已经使用 ng new dragonfly
和以下参数生成了一个新的Angular项目:
I have generated a new Angular project using ng new dragonfly
with the following parameters:
Angular v7.2
Angular CLI v.7.3
NPM 6.7.0
Windows 10
Angular v7.2
Angular CLI v.7.3
NPM 6.7.0
Windows 10
我选择包括路由和SCSS.
I've selected to include routing, and SCSS.
当我尝试使用 npm start
或 ng serve
启动项目时,在编译结束时会引发以下错误:
When I try to fire up the project using npm start
or ng serve
, toward the end of the compilation the following error gets thrown:
ERROR in multi ./src/styles.sass
Module not found: Error: Can't resolve
'C:\Users\S\angular\dragonfly\src\styles.sass' in
'C:\Users\S\angular\dragonfly'
i 「wdm」: Failed to compile.
angular.json
文件在项目示意图下列出了scss:
The angular.json
file lists scss under project schematics:
"schematics": {
"@schematics/angular:component": {
"style": "sass"
}
},
在Windows CLI和Bash CLI上,构建完全以相同的方式失败.文件styles.scss已创建,仅包含默认注释.
The build fails in Windows CLI, and Bash CLI on the same machine in the exact same way. The file styles.scss was created, and contains only a default comment.
我的配置是否被弄乱了,或者这可能是一个要报告的错误?任何见识都会很棒.我确实测试过使用CSS而不是SCSS生成项目,并且该项目可以编译并运行而没有问题.
Are my configs somewhere messed up, or, perhaps this is a bug to report? Any insight would be great. I did test generating the project using CSS instead of SCSS, and that one compiles and runs without problems.
更新:我的NodeJS安装已经过时,版本为8.9.1.我现在已经对其进行更新,并且正在运行10.15.1.结果是相同的.
Update: My NodeJS installation was outdated, at version 8.9.1. I've now updated it and am running 10.15.1. The results are identical.
推荐答案
更新: Angular 8已退出.与其应用下面列出的修复程序,不如考虑升级到v8.
确实是一个错误!官方问题在 https://github.com/angular/angular-cli/issues/13550 ,而 https://github.com/angular/angular-cli/issues/13551 提供了有关如何解决该问题的说明.简而言之,修改angular.json的
A bug indeed! The official issue is at https://github.com/angular/angular-cli/issues/13550 while https://github.com/angular/angular-cli/issues/13551 gives a description on how to get around it. In short, modify angular.json's
"styles": [
"src/styles.sass"
],
将 styles.sass
替换为 styles.scss
.
该问题已正式提交给Angular 7.3.在深入研究配置文件后,我在packager-lock.json中注意到了许多Angular 7.3版本.@ angular/core位于7.2.3,但@ angular-devkit/core已添加为7.3.0.
The issue is filed officially for Angular 7.3. After some digging around my config files, I am noticing a lot of Angular 7.3 versions in my packager-lock.json. @angular/core is at 7.2.3, but @angular-devkit/core is added as 7.3.0.
这篇关于Angular 7 CLI生成的项目抛出"multi./src/styles.sass中的错误".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!