Search code examples
angularintellij-ideaangular-cliangular-module

Class BrowserModule is not an Angular module


When I am creating a new angular project, it gives me error at imports in the 'app.module.ts' file.

The IDE error description screenshot here

Code:

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 { }

This has happened for the first time, can someone please suggest what is to be done.


Solution

  • Had the same issue. Just try to update everything. I updated WebStorm to a higher version and used 'ng update' to upgrade the project. Now the error is gone.