Home > Mobile >  Angular and Angular CLI version are same but ng build still fails
Angular and Angular CLI version are same but ng build still fails

Time:05-30

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/[email protected]

npm uninstall @angular/cli
npm install @angular/[email protected]

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

CodePudding user response:

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.

CodePudding user response:

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

  • Related