Home > Net >  How to get rid of "Conflicting Peer Depencies" error after new update
How to get rid of "Conflicting Peer Depencies" error after new update

Time:12-24

I've been trying to fix the dependencies of my project and usually I get it to work but I've been stuck on this forever now and it slowed down my progress to a halt. I saw another post where they said delete node_modules and the package-lock file and then use yarn to install everything but I can't even manage to install yarn.

Here are the errors I keep getting:

(base) Air-Aurelie:Wassupp aurelie$ npm i yarn
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@">=16.8.0" from @openspacelabs/[email protected]
npm ERR!   node_modules/@openspacelabs/react-native-zoomable-view
npm ERR!     @openspacelabs/react-native-zoomable-view@"^2.1.1" from the root project
npm ERR!   peer react@">=16.8.0" from @react-native-community/[email protected]
npm ERR!   node_modules/@react-native-community/hooks
npm ERR!     @react-native-community/hooks@"^2.8.1" from the root project
npm ERR!   25 more (@react-navigation/core, @react-navigation/elements, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.2.0" from [email protected]
npm ERR! node_modules/react-dom
npm ERR!   peer react-dom@">=16.8.0" from @zendeskgarden/[email protected]
npm ERR!   node_modules/@zendeskgarden/container-field
npm ERR!     @zendeskgarden/container-field@"^2.1.0" from @zendeskgarden/[email protected]
npm ERR!     node_modules/@zendeskgarden/react-forms
npm ERR!       @zendeskgarden/react-forms@"^8.62.0" from the root project
npm ERR!   peer react-dom@">=16.8.0" from @zendeskgarden/[email protected]
npm ERR!   node_modules/@zendeskgarden/container-focusvisible
npm ERR!     @zendeskgarden/container-focusvisible@"^1.0.0" from @zendeskgarden/[email protected]
npm ERR!     node_modules/@zendeskgarden/react-theming
npm ERR!       peer @zendeskgarden/react-theming@"^8.1.0" from @zendeskgarden/[email protected]
npm ERR!       node_modules/@zendeskgarden/react-forms
npm ERR!       1 more (the root project)
npm ERR!   7 more (@zendeskgarden/container-slider, ...)
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"^18.2.0" from [email protected]
npm ERR!   node_modules/react-dom
npm ERR!     peer react-dom@">=16.8.0" from @zendeskgarden/[email protected]
npm ERR!     node_modules/@zendeskgarden/container-field
npm ERR!       @zendeskgarden/container-field@"^2.1.0" from @zendeskgarden/[email protected]
npm ERR!       node_modules/@zendeskgarden/react-forms
npm ERR!         @zendeskgarden/react-forms@"^8.62.0" from the root project
npm ERR!     peer react-dom@">=16.8.0" from @zendeskgarden/[email protected]
npm ERR!     node_modules/@zendeskgarden/container-focusvisible
npm ERR!       @zendeskgarden/container-focusvisible@"^1.0.0" from @zendeskgarden/[email protected]
npm ERR!       node_modules/@zendeskgarden/react-theming
npm ERR!         peer @zendeskgarden/react-theming@"^8.1.0" from @zendeskgarden/[email protected]
npm ERR!         node_modules/@zendeskgarden/react-forms
npm ERR!         1 more (the root project)
npm ERR!     7 more (@zendeskgarden/container-slider, ...)
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! 
npm ERR! See /Users/aurelie/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/aurelie/.npm/_logs/2022-12-22T16_55_08_011Z-debug-0.log

Does anyone know how to get me out of this? Should I just start a new project and reinstall everything?

CodePudding user response:

It's not about reinstalling. Your dependencies come with peer dependency whose version constraints conflict with your project's dependencies. Imo you have three options:

  1. Solve the conflict. E.g. @zendeskgarden/container-field seems to require react 16.x.y (with x > 8) - and with same for react-dom -, so either you have to install a newer version of container-field with (hopefully) a newer peer-dependency (no guarantee that's the case, you've got to check it out), or you have to downgrade your project's dependencies to react 16.8.0 (or the latest of those, i.e. react 16.14.0) (same with react-dom). Either approache must be done in your package.json. Note that downgrading might require downgrades of other dependencies, too, if they depend on react 17 or react 18 while you're with react 16. You can give it a try and see how far you get. If it works, it's the cleanest and safest solution.
  2. You can try to run npm i --legacy-peer-deps. npm was more lenient back then, in most cases it won't cause any trouble. But you never know, you're actively ignoring version constraints.
  3. You can override peer dependencies in your package.json, which might cause issues similar to --legacy-peer-deps. For this, your package.json needs an entry like
  "overrides": {
    "@zendeskgarden/[email protected]": {
      "react": "18.2.0",
      "react-dom": "18.2.0"
    }
  },
  • Related