I am trying to update angular cli version locally, however everytime I run the following command I keep getting the following error:
npm uninstall –save-dev angular-cli. (trying to follow steps shown here)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @angular-devkit/build-angular@15.0.4
npm ERR! Found: @angular/compiler-cli@12.2.2
npm ERR! node_modules/@angular/compiler-cli
npm ERR! dev @angular/compiler-cli@"~12.2.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler-cli@"^15.0.0" from @angular-devkit/build-angular@15.0.4
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^15.0.4" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler-cli@15.0.4
npm ERR! node_modules/@angular/compiler-cli
npm ERR! peer @angular/compiler-cli@"^15.0.0" from @angular-devkit/build-angular@15.0.4
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^15.0.4" 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!
If I try to run command: npm install, I get the following too:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @angular-devkit/build-angular@15.0.4
npm ERR! Found: @angular/compiler-cli@12.2.2
npm ERR! node_modules/@angular/compiler-cli
npm ERR! dev @angular/compiler-cli@"~12.2.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler-cli@"^15.0.0" from @angular-devkit/build-angular@15.0.4
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^15.0.4" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler-cli@15.0.4
npm ERR! node_modules/@angular/compiler-cli
npm ERR! peer @angular/compiler-cli@"^15.0.0" from @angular-devkit/build-angular@15.0.4
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^15.0.4" 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!
Whatever I try I get the same error message and I have not found anything of value online. How can I get this to work?
>Solution :
Try the following commands
npm install –force
ng update @angular/core@15 @angular/cli@15 –force
Also enter this command so you wont have to use –force again. This should resolve the dependency conflicts
npm config set legacy-peer-deps true