skip to Main Content

I’ve cloned a git repository and am trying to run the app in the browser. The problem is that I used "npm install" and it didn’t install everything, I tried npm install again and I get these errors:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @angular-devkit/[email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   dev @angular/compiler-cli@"~10.0.0" from the root 
project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler-cli@"^16.0.0" from @angular- 
devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"^16.2.0" 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@"^16.0.0" from @angular- 
devkit/[email protected]
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"^16.2.0" 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.

How do I resolve this?
I tried to use the node version the project was created on, 14.15.1, but Visual Studio Code just kept saying that this version was no longer supported and asked me to update to the latest one.

Install and uninstall node, use different versions, delete node_modules folder,

2

Answers


  1. Try using the –legacy-peer-deps flag

    Like this:

    npm install --legacy-peer-deps
    

    You likely have packages in your package.json that rely on out of date/deprecated versions, and upgrading them would be breaking changes, so it gets stuck.

    Running with legacy peer deps (legacy peer dependencies) will go through your package lock json and search for last known good versions of peer dependencies to install.

    Here is a description about legacy peer deps from chat gpt:

    "As of NPM version 7, peerDependencies are installed by default. The –legacy-peer-deps flag was added in npm 7 as a way to ignore peer dependencies and proceed with the installation anyway.
    The –legacy-peer-deps option is generally safer and should be the preferred option when dealing with peer dependency conflicts. It ensures compatibility by falling back to older versions.
    The proper way to address issues related to peer dependencies is by updating your project’s dependencies to versions that are compatible with each other."

    Login or Signup to reply.
  2. The error message you’re encountering is related to a dependency conflict in your Angular project’s package.json file. It appears that there’s a mismatch between the versions of the @angular/compiler-cli package required by different parts of your project.

    Here’s how you can address this issue:

    Check Your Angular Version: The error message indicates that you’re using Angular version 10 (@angular/[email protected]). However, you’re trying to install or use a package (@angular-devkit/[email protected]) that requires Angular version 16. This is likely the source of the conflict.
    To resolve this issue, you should ensure that your project’s Angular packages are all at the same version. You can update the packages with proper migration.

    Or

    Use –force Flag: you can try using the –force flag with the npm install command. However, using this flag might lead to potential issues with compatibility, so it’s generally better to resolve the version conflicts manually. This will disable angular suggested protection.

    npm install --force
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search