Skip to content
Latchkey

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

ng
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

  1. Pin @angular/cli and @angular/core to the same major in package.json.
  2. Run ng update @angular/cli @angular/core locally to migrate together.
  3. Commit the updated package-lock.json and use npm ci in CI.
Terminal
ng update @angular/cli@17 @angular/core@17

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

.github/workflows/ci.yml
- run: npm ci

How to prevent it

  • Keep @angular/cli and @angular/* on the same major version.
  • Update the CLI and framework together with ng update.
  • Always npm ci in CI so resolved versions are reproducible.

Related guides

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