<SomeModule> 不是 Angular 模块

<SomeModule> is not an Angular module

使用 Angular 项目时,我正在导入核心 Angular NgModule,Webstorm 告诉我它们不是有效的 Angular 模块。

@NgModule({
    declarations: [AppComponent],
    imports: [
        BrowserModule, // Gets the error
        AppRoutingModule,
        SharedModule,
        HttpClientModule, // Gets the error
        UpgradeModule, // Gets the error
        CoreModule,
    ],
    providers: [],
    bootstrap: [AppComponent],
    schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}

我导入到 app.module 中的所有模块都出现红色波浪线,表示它们不是 Angular 模块。我不能忍受用这个看代码。谁看过这个吗?请帮忙。

我与 webstorm 团队进行了 Google 视频群聊,他们看到我的 node_modules 中的 none 被编入了索引。我打开了我的项目首选项并从我排除的目录中删除了 node_modules。完全奏效了。

  • 点击 Command + , 打开首选项。
  • 在您左侧的首选项菜单中搜索 Directories
  • 从右侧的排除部分中删除 node_modules
  • 保存并应用更改
  • 等待 Webstorm re-index 项目和节点模块。

成功了。

当我在 package.json 中输入错误时,我遇到了同样的问题。 Webstorm(和所有 JetBrains IDE)查看 package.json 以查看顶级 node_modules 是什么,因为它将索引那些。如果您的 package.json 中有拼写错误,您将收到这样的错误。

就我而言,我漏掉了一个逗号。