Angular "NG6002: appears in the NgModule.imports ... not an NgModule" in CI
NG6002 means a value listed in an NgModule's imports array does not resolve to an NgModule class. The AOT compiler cannot build the module graph, so the build fails.
What this error means
ng build fails with "error NG6002: 'X' appears in the NgModule.imports of 'AppModule', but could not be resolved to an NgModule class".
ng
error NG6002: 'WidgetComponent' appears in the NgModule.imports of 'AppModule',
but could not be resolved to an NgModule class.
Did you mean to import it into 'declarations' instead?Common causes
A component placed in imports instead of declarations
A non-standalone component or directive belongs in declarations, not imports; listing it under imports produces NG6002.
An imported symbol is not a module
A wrong import (a service, a const, or a missing export) put a non-NgModule value in the array.
How to fix it
Move the entry to the correct array
- Read which symbol NG6002 names.
- If it is a component/directive/pipe, move it to
declarations(or make it standalone and keep it inimports). - Re-run the build.
app.module.ts
@NgModule({
declarations: [WidgetComponent],
imports: [CommonModule],
})Fix a wrong import
Ensure the imported value is actually an NgModule; correct the import path or export if it is not.
How to prevent it
- Put components/directives/pipes in
declarations, modules inimports. - Prefer standalone components to avoid module-array confusion.
- Run AOT build in CI so module-graph errors surface early.
Related guides
Angular "NG8001: is not a known element" template error in CIFix Angular "error NG8001: 'X' is not a known element" in CI - the template uses a component or element whose…
Angular "NullInjectorError: No provider for X" in CIFix Angular "NullInjectorError: No provider for X" in CI - a service requested by DI was never provided, so u…
Angular "error TS" in component template type-check in CIFix Angular "error TSxxxx" raised by template type checking in CI - strictTemplates flags a binding whose typ…