Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmet peer dependency 'react-router' despite having 'react-router-dom' #250

Open
lightclient opened this issue Jan 26, 2019 · 6 comments
Open

Comments

@lightclient
Copy link

lightclient commented Jan 26, 2019

I'm getting a warning during package installations saying the following:

connected-react-router@6.2.2" has unmet peer dependency "react-router@^4.3.1"

However, I have react-router-dom as a dependency already which installs react-router. It seems to be working correctly, but it feels like a bug that connected-react-router doesn't realize I have a package which install react-router.

Please advise.

@imjoshdean-tc
Copy link

@supasate Is there any code in connected-react-router that has actual dependencies that aren't in react-router-dom? If not, can we just change the peer dependency to react-router-dom instead of react-router?

@govizlora
Copy link

+1 For this. According to the docs here: https://github.com/ReactTraining/react-router/tree/master/packages/react-router#installation , user would install either react-router-dom or react-router-native, instead of react-router.

@diegofelipece
Copy link

diegofelipece commented Sep 18, 2019

I'm having the same issue, and I have to admit that I don't really get if the problem is on connected-react-router package.json, or some npm bug, or some misunderstanding mine of how peerDependencies work.
Anyway, what sounds really weird to me is that these warnings seem supposed to alert us that we have an incompatible version of the package installed (react-router on this case), which is not true in this case, so why we still seeing that?

So, this is my warning:

warning " > connected-react-router@6.5.2" has unmet peer dependency "react-router@^4.3.1 || ^5.0.0".

And since I'm using react-router-dom@5.0.1 my installed version of react-router is also 5.0.1, which attends perfectly the demands of ^4.3.1 || ^5.0.0

Should I always add react-router as a dependency of my project? Even if I already the right version?

Man, I would be very happy to understand that, haha

@ymeskini
Copy link

ymeskini commented Feb 3, 2020

you can ignore this warning because react-router is installled along with react-router-dom, you can check in your node_modules and you'll find react-router directory

@ateev
Copy link

ateev commented Feb 17, 2020

I had the same issue, not just the common unmet dependency error, the error is in the Chrome console and bundle build too.

@mdrx-io
Copy link

mdrx-io commented May 15, 2020

AFAIK, the peer dependencies npm/yarn check only looks if they are specified in the top level of your package.json. It won't be satisfied if there is a private dependency like that of react-router inside react-router-dom. More explanation here: https://stackoverflow.com/questions/26737819/why-use-peer-dependencies-in-npm-for-plugins

It's kind of a flaw in the package managers that they don't give a package author the ability to specify one package or a completely different one. But this problem also came about with how the authors of react-router split up their packaging. Maybe the author(s) of connected-react-router should just switch over the peer-dependency to the one that most people are using (react-router-dom) rather than the safe bet that is react-router?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants