Solving the Angular Update Error: Conflicting peer dependency

If you’re struggling to update your Angular version and encounter the following error when executing the command ‘npm install upgrade angular’:

npm ERR! Conflicting peer dependency: @angular/compiler@15.2.9
npm ERR! node_modules/@angular/compiler
npm ERR! peer @angular/compiler@"15.2.9" from @angular/localize@15.2.9
npm ERR! node_modules/@angular/localize
npm ERR! peerOptional @angular/localize@"^15.0.0" from @angular-devkit/build-angular@15.2.9
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^15.2.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.
npm ERR!

Here’s a potential solution:

Delete the ‘node_modules’ folder and the ‘package-lock.json’ file, then reinstall npm. This could resolve your issue.

To do this, execute the following commands:

  1. Delete ‘node_modules’
  2. Delete ‘package-lock.json’
  3. Run ‘npm install’