I have an existing project that was developed with Angular version 13, now I'm asked to migrate to higher version (version 16).
I read in some Stack Overflow questions and the docs that I should upgrade version by version, so I started from 13 -> 14.
After following the instructions from the docs, I get the following error every time I want to run the project I get the following error:
This version of CLI is only compatible with Angular versions ^13.0.0 || ^13.3.0-rc.0,
but Angular version 14.3.0 was found instead.
Please visit the link below to find instructions on how to update Angular.
https://update.angular.io/
I followed the docs that said that I have to run ng update @angular/core@14 @angular/cli@14
, I also installed version 14 of the Angular CLI globally.
Running npm run ng version
gives me the following result:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 14.2.10
Node: 18.16.1 (Unsupported)
Package Manager: npm 10.8.2
OS: win32 x64
Angular: 14.3.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1303.11
@angular-devkit/build-angular 13.3.11
@angular-devkit/core 13.3.11
@angular-devkit/schematics 14.2.10
@angular/cdk 13.3.9
@angular/material 13.3.9
@nguniversal/express-engine 13.1.1
@schematics/angular 14.2.10
rxjs 7.8.1
typescript 4.6.3
Seems you have a mix of 13 and 14 versions installed in there.
Try installing latest 13.x
versions for @angular-devkit/schematics
, @schematics/angular
and rest of Angular 14.x
packages you have actually installed (CLI too) first
You can do so by npm i @angular-devkit/schematics@13 @schematics/angular@13
for all packages that you have now installed with version v14.x
. Then upgrade them as usual.
In this regard what I usually do is run the project's installed Angular CLI to perform the update to avoid errors like this. Angular CLI is clever enough to use a newer version in order to perform the upload
Run
npm run ng update @angular/cli@14 @angular/core@14
And it will use the project's Angular CLI v13 to perform the update. Which in turn will download a newer one in order to proceed (but it will automatically choose a compatible one)
This way no need to install a global one also :)
I actually try to avoid installing anything globally to avoid issues like this one when switching between projects