Why the version check fails
When you run `ng serve`, the Angular CLI reads the version of the framework installed in the project (from `package.json`). If the CLI binary you invoke (often the global one) expects a different Angular range, it aborts with the compatibility error. In this case the global CLI is from the 8.x line, while the project uses Angular 9.x, so the range check rejects the command.
Inspect the CLI versions you are actually using
Run the following commands from your project root:
- `ng version` – shows the version of the CLI that is executed (usually the global one). - `npm list @angular/cli` – displays the version that is installed locally in `node_modules`. - `npm list @angular/core` – confirms the Angular framework version.
If the global CLI version is older than the framework version, you need to either upgrade the global CLI or force the project to use its local copy.
ng version
npm list @angular/cli
npm list @angular/core
Upgrade the global CLI or use the local CLI
The simplest fix is to install the matching CLI globally:
```bash npm uninstall -g @angular/cli npm install -g @angular/cli@9.1.12 # or any 9.x version that matches your project ```
If you prefer not to touch the global installation, you can run the local binary directly with `npx` or an npm script:
```bash npx ng serve # uses the locally installed CLI npm run start # start script already points to ng serve ```
Align the devDependencies with Angular 9
Your `package.json` mixes Angular 8 and 9 packages (`@angular/cdk` 8.1.3, `@angular/material` 8.1.3) while the core framework is 9.0.0‑next. This can cause hidden mismatches. Update all Angular packages to the same major version:
```bash ng update @angular/core @angular/cli npm install @angular/cdk@9 @angular/material@9 --save ```
After updating, delete `node_modules` and reinstall:
```bash rm -rf node_modules package-lock.json npm install ```
ng update @angular/core @angular/cli
npm install @angular/cdk@9 @angular/material@9 --save
Verify and run the application
Run `ng version` again to confirm that both the CLI and Angular core report the same major version (9.x). Then start the development server:
```bash ng serve # or npx ng serve if you rely on the local CLI ```
The compatibility error should disappear, and the app will compile with the correct packages.
Takeaway: Make sure the global or local Angular CLI version matches the Angular framework version declared in your project.
People also ask
Can I have multiple Angular CLI versions installed on the same machine?
Yes. Install the needed version locally in each project and invoke it with `npx ng` or through npm scripts to avoid global conflicts.
What does `ng update` do?
`ng update` analyses package versions, applies necessary migrations, and upgrades Angular core and CLI packages to a compatible set.
Why does `npm uninstall -g @angular/cli` sometimes leave old binaries?
Some systems keep a cached copy in the PATH. After uninstalling, verify the path with `which ng` (Unix) or `where ng` (Windows) and delete any stray binaries.
Inspired by a public discussion on Stack Overflow. This article is an original explanation for learners.