Angular "This version of CLI is only compatible with Angular versions" in CI
The Angular CLI checks that its major version lines up with @angular/core. When a CI install resolves a CLI major that differs from the framework major, the CLI refuses to run and prints the compatible range.
What this error means
ng build or ng test aborts with "This version of CLI is only compatible with Angular versions ^17.0.0, but Angular version 16.2.0 was found instead" (numbers vary).
This version of CLI is only compatible with Angular versions ^17.0.0,
but Angular version 16.2.0 was found instead.
Please visit https://update.angular.io/ to update your project.Common causes
CLI and framework majors drifted apart
A loose caret range let npm resolve @angular/cli to a newer major than @angular/core (or vice versa) during the CI install.
A stale or missing lockfile in CI
Without a committed lockfile, npm install picks the newest allowed versions, which can straddle a major boundary between the CLI and the framework.
How to fix it
Align CLI and framework majors, then lock
- Pin @angular/cli and @angular/core to the same major in package.json.
- Run
ng update @angular/cli @angular/corelocally to migrate together. - Commit the updated package-lock.json and use
npm ciin CI.
ng update @angular/cli@17 @angular/core@17Install from the lockfile in CI
Use npm ci, not npm install, so CI installs exactly the versions your lockfile resolved and the majors cannot drift.
- run: npm ciHow to prevent it
- Keep @angular/cli and @angular/* on the same major version.
- Update the CLI and framework together with ng update.
- Always
npm ciin CI so resolved versions are reproducible.