Reputation: 417
I've updated my npm packages, now i keep getting this error: "Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead."
I tried this ways, but no output: 1.Import BrowserModule and BrowserAnimationsModule only once in app.module.ts, but still getting the same Issue. 2. import BrowserModule once in app.module.ts,In Other modules import CommonModules instead. 3. Remove BrowserModule from app.module.ts because BrowserAnimationsModule by default import BrowserModule 4. Place BrowserModule on Top of app.module.ts
This is my app.module.ts file code
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpModule,
BrowserTransferStateModule,
RouterModule.forRoot(appRoutes),
ToastrModule.forRoot(),
CommonMaterialModule,
FlexLayoutModule
],
This is my shared.module.ts file code
imports: [
CommonModule,
CommonMaterialModule,
ChartsModule,
FormsModule,
FlexLayoutModule,
MatExpansionModule,
ReactiveFormsModule,
CollapseModule,
MatDialogModule
],
I tried every way mention in stack overflow to solve issue but getting the same issue. anyone can please help to solve the problem.
Upvotes: 2
Views: 740
Reputation: 417
After a lot of research finally, I got the solution just update angular platform browser dependency which contains BrowerModule.
npm i @angular/platform-browser
Upvotes: 1
Reputation: 5742
imports: [
BrowserModule<----- comment this
BrowserAnimationsModule,
HttpModule,<----------------- put this after browser transfer
BrowserTransferStateModule,
RouterModule.forRoot(appRoutes),
ToastrModule.forRoot(),
CommonMaterialModule,
FlexLayoutModule
],
Import BrowserAnimationsModule and HttpModule only once (either in your root module or a core module)
.
Upvotes: 0