I am getting above error even though I have imported CommonModule in all related modules having NgIf or NgFor and BrowserModule is only imported once in app.module.ts

app.module.ts

What else I can do please help me. Angular version enter image description here Error Message enter image description here

Also I have migrated my project to be standalone component still it is not resolved as I read some solution like this also.

3

There are 3 best solutions below

1
Matthieu Riegler On

The BrowserAnimationModule also pulls the BrowserModule.

Remove the BrowserModule and you should be fine !

1
hadi kashlan On

I had same issue.

My issue was because I was importing the [BrowserAnimationsModule](https://github.com/angular/angular/blob/main/packages/platform-browser/animations/src/module.ts#L34) which is re-exporting BrowserModule.

I removed it from app.module and imported it where I needed it.

BTW if you are using Angular 17 with bootstrapApplication, you can remove this module and use provideAnimations().

0
kian On

I had this issue in angular v.17.

in app.config.ts file I added provideAnimations() in providers.It's not related to CommonModule.

export const appConfig: ApplicationConfig = {
  providers: [provideRouter(routes), provideAnimations()],
};