我正在对使用 angular-cli 生成的项目进行更改,但似乎某些文件卡在缓存中,节点没有意识到它并不断向我发送错误消息
ERROR in D:/Workspace/NodeJs/TrackEditor/src/app/pages/pages/pages.component.ts (6,5): Argument of type '{ selector: string; templateUrl: string; stylesUrl: string[]; }' is not assignable to parameter of type 'Component'.
Object literal may only specify known properties, and 'stylesUrl' does not exist in type 'Component'.
webpack: Failed to compile.
我更正了 pages.component.ts 但它没有进行更改。
import { Component } from '@angular/core';
@Component({
selector: 'app-pages',
templateUrl: './pages.component.html',
styleUrls: ['./pages.css']
})
export class PagesComponent {}
某种清除缓存并重新编译项目的方法。
谢谢
我碰巧 webpack 无法识别某些更改,因此建议您取消项目的执行并返回给用户
ng serve
,或者npm start
取决于您决定运行它以满足其需要。如果仍然有问题,请再次运行
npm install
以更新node_modules文件夹。如果确实需要清除缓存,请使用以下命令:
npm cache clean
显示的问题是angular-cli问题而不是NodeJs,我不知道组件代码是从终端生成的还是手动编写的,如果是手动编写的,请删除文件夹并运行ng generate component命令(组件名称),在这种情况下是 pagescomponent。
要么你有错误的' app.module.ts '中的新组件的信息,要么你放在'@Component'下的一些文件(选择器,模板Url或styleUrls)不存在。
最正常的就是第一个,类名、所在的路径或者文件名在‘app.module.ts’中没有正确指明。