jgf*_*jgf 13 javascript typescript angular
我正在开发一个使用 Angular 8 的项目。最近我开始在所有模块中出现错误。当我将鼠标悬停在 commonModule 导入上时,我收到以下错误消息:
'CommonModule' does not appear to be an NgModule class.(-996002)
common.d.ts(43, 57): This likely means that the library (@angular/common) which declares CommonModule is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
Run Code Online (Sandbox Code Playgroud)
我还收到 html 文件中每个指令的错误,例如:
Can't bind to 'ngClass' since it isn't a known property of 'div'.ngtsc(-998002)
Run Code Online (Sandbox Code Playgroud)
我尝试过在网上找到的解决方案,但没有一个对我有用。我尝试删除节点模块文件夹,然后运行 npm install。我还在 VScode 的 Angular 语言服务设置中启用了旧版视图引擎。当我将 VSCode 的 typescript 版本更改为项目的 package.json 中使用的版本时,问题似乎解决了,但很快错误又回来了。有人知道发生了什么事吗?
小智 2
它似乎与 VSCode 有关,以下解决方法对我有用,我已经:
npm cache clean --forcenpm install,然后npm start在与 VSCode 终端不同的终端(在我的例子中为 iTerm2)中从项目根目录执行了操作。这允许重新编译项目并且 VSCode 中的错误消失了| 归档时间: |
|
| 查看次数: |
6225 次 |
| 最近记录: |