angular - <SomeModule> 不是 Angular 模块

标签 angular webstorm

当使用 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 Hangout,他们发现我的任何 node_modules 都没有被编入索引。我打开了项目首选项,并从排除的目录中删除了 node_modules。完全有效。

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

它成功了。

关于angular - <SomeModule> 不是 Angular 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57168592/

相关文章:

angular - 如何将类注入(inject)服务[Angular 6]

angular - 如何从 Javascript 在 Cloud Firestore 中创建集合?

node.js - 使用 Node.js 和 TypeScript 的正确方法是什么?

javascript - Webstorm SystemJS 导入解决错误

firebase - 使用带有 IntelliJ Ultimate/WebStorm 的模拟器调试本地 Firebase 函数时不触发断点

html - 如何以 Angular 解析嵌套的json

Angular 2 RxJS 检查鼠标事件在延迟后是否仍然有效

angular - Angular 信号在模板中使用安全吗?

webstorm - 如何在 WebStorm VCS 操作弹出窗口中编辑操作列表?

javascript - 为什么这里的变量声明据说是多余的