angular - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class

ID : 20212

viewed : 17

Tags : angulargoogle-cloud-firestoreangularfireangular

Top 5 Answer for angular - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class

vote vote

97

Your module is not yet loaded by the Angular Server in node ng serve, so restart your server so the server loads the module that you just added in @NgModule app.module.ts

vote vote

88

This error shows when you add component declaration in imports: [] instead of declarations: [], e.g:

declarations: [   AppComponent, ], imports: [   BrowserModule,   AppRoutingModule,   SomeComponent <-----------wrong ], 
vote vote

74

I got this error when I made the bonehead mistake of importing MatSnackBar instead of MatSnackBarModule in app.module.ts.

vote vote

68

I made a mistake by adding a service into imports array instead of providers array.

@NgModule({   imports: [     MyService // wrong here   ],   providers: [     MyService // should add here   ] }) export class AppModule { } 

Angular says you need to add Injectables into providers array.

vote vote

54

Fixed it by opting out of Ivy as per documentation.

https://angular.io/guide/ivy

Change tsconfig.app.json to opt out of Ivy.

"enableIvy": false 

Top 3 video Explaining angular - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class

Related QUESTION?