DEV Community


Posted on

Understanding Peer Dependencies

I'm fairly new to react, as in I just started building UI's with it about a month ago.

I ran into an error recently that I have a slight idea what it means, but I'm not sure how to resolve it.

npm install react-plaid-link       
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: frontend@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from react-plaid-link@3.1.0
npm ERR! node_modules/react-plaid-link
npm ERR!   react-plaid-link@"*" 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.
Enter fullscreen mode Exit fullscreen mode

If I understand this correctly, react-plaid-link uses react 16.8 as a dependency, but I have react 17 installed and so it won't work?

Is that a correct understanding of this error? How do I resolve this? Can I downgrade? Should I?

Any help would be greatly appreciated.

Top comments (1)

aroman012 profile image
Alejandro Roman

Hi Ron!

Yes, it's something like that: react-plaid-link has a peer dependency of react 16.8. What's the difference? Well, a dependency means that your project needs a library to work. A peerDependency means that your project will be attached (or plugged in) into another project, and it will be run as part of that project.

Starting from npm 7, peerDependencies are automatically installed together with normal dependencies, but if npm finds a version mismatch (like this case), it will abort the installation.

Your solution would be to either:

  • Downgrade your react version to 16.8, so you comply with react-plaid-link's peer dependency.
  • Ignore the peer dependency (it may break something though) and just continue with react 17. You can do this with npm install react-plaid-link --legacy-peer-deps.
  • Wait until the mantainers of react-plaid-link change the peer dependency so that their library supports react 17.

PD: This question was posted a month ago and, since then, the developers have added support for react 17