Skip to content
Latchkey

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

  1. 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

  1. 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

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