Angular "No NgModule metadata found for" in CI
The compiler was handed a class as an NgModule (in bootstrap, TestBed, or a lazy route) but that class has no @NgModule decorator. The reference points at the wrong class, or the decorator is missing.
What this error means
The build or a unit test fails with "No NgModule metadata found for 'AppComponent'" or a similar class name where a module was expected.
Error: No NgModule metadata found for 'AppComponent'.Common causes
A component passed where a module is required
bootstrapModule, a lazy loadChildren, or TestBed.configureTestingModule was given a component or plain class instead of an @NgModule class.
A missing or stripped @NgModule decorator
The intended module class lost its @NgModule decorator, or an import resolved to the wrong file exporting a same-named class.
How to fix it
Point the reference at the real NgModule
- Confirm the class you bootstrap or lazy load is decorated with @NgModule.
- Fix the import so it references the module file, not a component.
- Rebuild or re-run the test.
platformBrowserDynamic()
.bootstrapModule(AppModule);Use the standalone bootstrap API where appropriate
For standalone apps, bootstrap the root component with bootstrapApplication instead of an NgModule.
bootstrapApplication(AppComponent, appConfig);How to prevent it
- Bootstrap and lazy load modules, not components.
- Keep @NgModule on every module class.
- Match standalone vs NgModule bootstrap to your app style.