I am trying to update the current Angular 12 app to 13 using the official upgrade guide, but it fails. I am not sure what the issue is, frankly, I don't think the npm error messages are self-explanatory.
Here is the output:
PS C:\Projects\frontend> npx ng update @angular/cli@13
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 13.3.9 to perform the update.
✔ Package successfully installed.
Using package manager: 'npm'
Collecting installed dependencies...
Found 46 dependencies.
Fetching dependency metadata from registry...
Updating package.json with dependency @angular-devkit/build-angular @ "13.3.9" (was "12.2.18")...
Updating package.json with dependency @angular/cli @ "13.3.9" (was "12.2.18")...
Updating package.json with dependency @angular/compiler-cli @ "13.3.11" (was "12.2.16")...
Updating package.json with dependency typescript @ "4.6.4" (was "4.3.5")...
Updating package.json with dependency @angular/animations @ "13.3.11" (was "12.2.16")...
Updating package.json with dependency @angular/common @ "13.3.11" (was "12.2.16")...
Updating package.json with dependency @angular/compiler @ "13.3.11" (was "12.2.16")...
Updating package.json with dependency @angular/core @ "13.3.11" (was "12.2.16")...
Updating package.json with dependency @angular/forms @ "13.3.11" (was "12.2.16")...
Updating package.json with dependency @angular/platform-browser @ "13.3.11" (was "12.2.16")...
Updating package.json with dependency @angular/platform-browser-dynamic @ "13.3.11" (was "12.2.16")...
Updating package.json with dependency @angular/router @ "13.3.11" (was "12.2.16")...
UPDATE package.json (2773 bytes)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~13.3.9" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~13.3.9" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/[email protected]
npm ERR! node_modules/@angular/compiler-cli
npm ERR! peer @angular/compiler-cli@"^13.0.0 || ^13.3.0-rc.0" from @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~13.3.9" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Can someone tell me what the issue is and how to upgrade?
CodePudding user response:
This error appears because you have node 16.X or newer. Npm is stricter than before. Solution 1: downgrade your node version
Solution 2: fix those erros by upgrading build-angular to 13.3.9