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 matches @angular/core. When a globally installed or mismatched CLI runs against a project on a different major, it refuses with a compatibility error.

What this error means

ng build or ng test stops with "This version of CLI is only compatible with Angular versions ^X, but Angular version Y was found instead".

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

Common causes

A global CLI shadows the project CLI

A globally installed @angular/cli on a different major runs instead of the project-local one, so the versions disagree.

The project CLI and core are on different majors

A partial upgrade left @angular/cli and @angular/core on different majors in package.json.

How to fix it

Run the project-local CLI

  1. Invoke the CLI through npx or package.json scripts so the local version is used.
  2. Avoid relying on a globally installed ng.
  3. Re-run the build.
Terminal
npx ng build   # uses the project-local CLI, not a global one

Align CLI and core majors

Bring @angular/cli and @angular/core to the same major and reinstall.

Terminal
npm install -D @angular/cli@17
npm install @angular/core@17

How to prevent it

  • Always run ng via npx or npm scripts in CI, never a global install.
  • Upgrade CLI and core together to the same major.
  • Commit the lockfile so CLI and core versions are pinned.

Frequently asked questions

What causes ""only compatible with Angular versions""?
A globally installed @angular/cli on a different major runs instead of the project-local one, so the versions disagree.
How do I fix "only compatible with Angular versions"?
Run the project-local CLI

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card