Skip to content
Latchkey

Angular "Cannot find module @angular/compiler-cli" - Fix in CI

The Angular AOT build needs @angular/compiler-cli. It is missing from node_modules, or its version does not match @angular/core, so the compiler cannot load.

What this error means

The build fails with Cannot find module '@angular/compiler-cli' or a version-mismatch error against @angular/core.

angular
Error: Cannot find module '@angular/compiler-cli'
Require stack:
- /app/node_modules/@angular-devkit/build-angular/src/...

Common causes

compiler-cli not installed

The package is missing as a devDependency or was pruned by a production-only install.

Version mismatch with @angular/core

compiler-cli and core are on different Angular versions, so the compiler refuses to load.

How to fix it

Install a matching compiler-cli

  1. Install @angular/compiler-cli at the same version as @angular/core.
Terminal
npm install -D @angular/compiler-cli@$(npm ls @angular/core --json | node -e "process.stdout.write(JSON.parse(require('fs').readFileSync(0)).dependencies['@angular/core'].version)")

Keep dev deps for the build

  1. Do not omit dev dependencies before ng build.
Terminal
npm ci   # not --omit=dev

How to prevent it

  • Upgrade all @angular/* packages together to keep versions aligned.
  • Run the build job with dev dependencies installed.

Related guides

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