Angular error: Please add a @NgModule annotation

You’re trying to “import” a component in SomeModule.

imports: [
  CommonModule,
  SomeComponent
],

You import modules and declare components, which is exactly what the error message tells you — you tried importing a directive SomeComponent.

Unexpected directive ‘SomeComponent’ imported by the module ‘SomeModule’.

Move the SomeComponent from imports to declarations.

imports: [
  CommonModule,
],
providers: [SomeService],
declarations: [
  SomeComponent,
],

Leave a Comment