Skip to content
Latchkey

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

  1. Read which symbol NG6002 names.
  2. If it is a component/directive/pipe, move it to declarations (or make it standalone and keep it in imports).
  3. 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 in imports.
  • Prefer standalone components to avoid module-array confusion.
  • Run AOT build in CI so module-graph errors surface early.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →