0

Here is output of ng v:

Angular CLI: 9.1.13
Node: 12.22.12
OS: win32 x64

Angular: 9.1.13

Surprisingly when I type ng build I get this error:

This version of CLI is only compatible with Angular versions ^13.0.0 || ^13.3.0-rc.0,
but Angular version 9.1.13 was found instead.

In other similar questions Angular CLI version were higher or lower than Angular version and with an upgrade or downgrade PO could usually solve the problem. However, in this case Angular CLI and Angular version is the same and I still receive the error.

I tried all this commands:

npm uninstall -g @angular/cli
npm cache verify --force
npm install -g @angular/cli@9.1.13

npm uninstall @angular/cli
npm install @angular/cli@9.1.13

npm install

Update:

As @Yanis-git asked in comments I run ng --version in \node_modules\.bin:

Angular CLI: 9.1.13
Node: 12.22.12
OS: win32 x64

Angular: 9.1.13
... cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.19
@angular-devkit/build-angular   13.3.7
@angular-devkit/build-webpack   0.1303.7
@angular-devkit/core            13.3.7
@angular-devkit/schematics      13.3.7
@angular/animations             9.1.12
@angular/cdk                    10.2.5
@angular/fire                   6.1.4
@angular/google-maps            9.2.4
@angular/http                   4.4.7
@ngtools/webpack                13.3.7
@schematics/angular             13.3.7
@schematics/update              0.901.13
rxjs                            6.6.7
typescript                      3.6.5
webpack                         5.70.0
Sri
  • 437
  • 1
  • 4
  • 13
Masoud Keshavarz
  • 2,166
  • 9
  • 36
  • 48
  • 1
    What version of node You have? Did You try do this in docker? You have error in 'npm cache verify --foroce', are You sure, that was run corect – Arek Szumacher May 30 '22 at 05:24
  • Hello Massoud, could you please going to your project, run `./node_modules/.bin/ng --version` ? i suspect a conflict between your global and local installation. – Yanis-git May 30 '22 at 05:26
  • Sorry it was a typo in the question. I fixed it: `npm cache verify --force`. Node version is `12.22.12` – Masoud Keshavarz May 30 '22 at 05:26

3 Answers3

0

You need to check that your angular CLI version is compatible with the node.js version that you have installed on your machine. From it looks like your node.js version is ahead of your current installed angular CLI.

you can check the below link for a compatible node.js version with angular CLI.

Node.js compatible version with Angular

I hope it's works for you.

Meet
  • 328
  • 3
  • 15
  • Thank you for the reply but I don't think its the reason. If I try node `v10.24.1` it says: `The Angular CLI requires a minimum Node.js version of either v12.20, v14.15, or v16.10`. Now I'm using `V12.22.12`. I'm trying to install `V12.20` instead of `V12.22` to test. – Masoud Keshavarz May 30 '22 at 05:41
0

It looks like you have partially upgrade your angular package :

Angular CLI: 9.1.13
Node: 12.22.12
OS: win32 x64

Angular: 9.1.13
... cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.19 // outdated.
@angular-devkit/build-angular   13.3.7 
@angular-devkit/build-webpack   0.1303.7 // should probably being removed.
@angular-devkit/core            13.3.7
@angular-devkit/schematics      13.3.7
@angular/animations             9.1.12 // should be upgrade.
@angular/cdk                    10.2.5 // should be upgrade.
@angular/fire                   6.1.4 // probably outdated.
@angular/google-maps            9.2.4 // Should be upgrade.
@angular/http                   4.4.7 // does not exist anymore.
@ngtools/webpack                13.3.7
@schematics/angular             13.3.7
@schematics/update              0.901.13 // should be upgrade.
rxjs                            6.6.7 // should be upgrade,
typescript                      3.6.5 // should be upgrde.
webpack                         5.70.0

Some refer to the latest version and some not. I have try to point which need to be updated.

what i recommend is to create a fresh angular cli project:

  • Require all your dependencies on it
  • replicate resolved version on the main project.

side note I don't know if it is required by your project, but you should probably not require webpack and @angular-devkit/build-webpack

Yanis-git
  • 7,737
  • 3
  • 24
  • 41
0

Check compatibility with your project.

And you can use NVM(Node Version Manager).

Resource: https://github.com/coreybutler/nvm-windows#installation--upgrades

Maizied Hasan Majumder
  • 1,197
  • 1
  • 12
  • 25