Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 需要修复模块中未找到的错误-角度_Javascript_Angular_Typescript - Fatal编程技术网

Javascript 需要修复模块中未找到的错误-角度

Javascript 需要修复模块中未找到的错误-角度,javascript,angular,typescript,Javascript,Angular,Typescript,我正在练习angular,但在编译代码时收到此错误: Module not found: Error: Can't resolve './app.component.css' in 'D:\hello-world-app\src\app' i 「wdm」: Failed to compile. My app.component.html Angular 我的课程 //tslint:禁用下一行:导入间距 从'@angular/core'导入{Component}; @组成部分({ 选择器:“课

我正在练习angular,但在编译代码时收到此错误:

Module not found: Error: Can't resolve './app.component.css' in 'D:\hello-world-app\src\app'
i 「wdm」: Failed to compile.
My app.component.html

Angular
我的课程

//tslint:禁用下一行:导入间距
从'@angular/core'导入{Component};
@组成部分({
选择器:“课程”//
模板:“课程”
})
导出类课程组件{
}
我的app.component.ts


从'@angular/core'导入{Component};
@组成部分({
选择器:'应用程序根',
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent{
title=‘hello world应用程序’;
}
我的app.module.ts

从'@angular/platform browser'导入{BrowserModule};
从“@angular/core”导入{NgModule};
从“./app.component”导入{AppComponent};
从“./courses.component”导入{CoursesComponent};
@NGD模块({
声明:[
应用组件,
课程组成
],
进口:[
浏览器模块
],
提供者:[],
引导:[AppComponent]
})
导出类AppModule{}

Angular无法找到(解析)文件,正如错误所述。为了修复错误,您需要添加文件,或者删除行
styleurl:['./app.component.css']

如果不希望避免文件引用并且正在使用(如果不希望,则可能应该使用),则可以在生成组件时使用
--inlineStyle=true
。当然,如果您使用的是angular cli,则css文件应该在生成组件时创建


很可能是你复制粘贴了一些东西,或者错误地删除了那个文件。无论哪种方式,Angular在找不到您所引用的内容时总是会抱怨。(与几乎所有其他编程框架/系统/语言一样)

是否有一个名为
app.component.css
的文件与
app.component.ts
位于同一目录下?查看
D:\hello world app\src\app\app.component.css
文件是否存在,如果没有,请调整组件中的路径。不要有名为app.component.css sir@Jacques的文件ジャック删除行
styleUrls:['./app.component.css']
,因为angular正在尝试查找(解析)该文件,但失败。因此,它无法编译。(正如错误所述)