supasate / connected-react-router

A Redux binding for React Router v4
MIT License
4.72k stars 593 forks source link

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

Open lightclient opened 5 years ago

lightclient commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

+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 commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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?