Angular AOT Compile Error (NGxxxx) - Fix in CI
Production builds use AOT, which type-checks templates strictly. Issues a JIT dev build tolerates - a missing declaration, a bad binding, a not-imported module - fail AOT with an NGxxxx code.
What this error means
The production build fails with an error NGxxxx: message pointing at a template or component.
angular
Error: src/app/foo/foo.component.html:5:8 - error NG8001:
'app-bar' is not a known element:
1. If 'app-bar' is an Angular component, verify it is part of this module.Common causes
Component not imported/declared
A template uses a component or directive that is not imported into the standalone component or declared in a module.
Template type error
Strict template type checking catches a binding to a non-existent property or a type mismatch.
How to fix it
Import the missing component
- Add the component to the standalone imports (or module declarations).
foo.component.ts
@Component({ standalone: true, imports: [BarComponent], template: '<app-bar />' })Fix the template binding
- Bind to a property that exists with a compatible type; address the NG code in the message.
How to prevent it
- Build with AOT locally before pushing so template errors surface early.
- Keep strict template type checking on to catch issues at compile time.
Related guides
Angular "Module build failed" - Fix in CIFix "Module build failed" during ng build in CI - a loader, a SCSS error, or a bad import breaks compilation…
Angular Budget Exceeded - Fix in CIFix "budgets exceeded" in ng build in CI - the initial or anyComponentStyle bundle grew past the configured b…
Angular "Cannot find module @angular/compiler-cli" - Fix in CIFix "Cannot find module @angular/compiler-cli" in CI - the AOT compiler package is missing or version-mismatc…