【问题标题】:Class BrowserModule is not an Angular module类 BrowserModule 不是 Angular 模块
【发布时间】:2022-01-07 09:53:42
【问题描述】:

当我创建一个新的 Angular 项目时,在“app.module.ts”文件中导入时会出错。

代码:

import { NgModule } from '@angular/core';
import {BrowserModule} from "@angular/platform-browser";

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,    //error here
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

这是第一次发生,有人可以建议要做什么。

【问题讨论】:

  • 该错误是仅在IDE中可见还是在您尝试编译项目时弹出?
  • 试过 npm 安装?也许之前也删除你的 node_modules 文件夹,重新安装
  • 请提供更多详细信息:确切的错误是什么?它说什么?它在何时何地弹出?
  • @PhilippMeissner 是的,仅在 IDE 中可见。我能够编译和运行程序。
  • @AndreasRainer 我已经编辑了问题并附上了 IDE 错误截图和描述。而且我已经尝试过重新安装。

标签: angular intellij-idea angular-cli angular-module


【解决方案1】:

有同样的问题。 只是尝试更新所有内容。我将 WebStorm 更新到更高版本并使用“ng update”来升级项目。现在错误消失了。

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2021-07-26
  • 2019-11-28
  • 2021-08-12
  • 1970-01-01
  • 2017-12-28
  • 2020-02-23
  • 1970-01-01
  • 2020-10-24
  • 2020-06-08
相关资源
最近更新 更多