1

There are a number of questions here on SO, which deal with the problem of conflicting/missing peer dependency, but they all seem to be directed at a very specific library (or got no answer at all).

I would like to know how to solve this problem in general. When a dependency requires a specific version of another lib and I have a newer version installed (example: React 17.0.1 as project dependency, react@^15.3.0 || ^16.0.0-alpha, required by react-virtualized-auto-sizer@1.0.4), how can I fix this situation?

So far I ignored the warning and the application seems to work fine. But I don't want to rely only on the current appearance.

Somewhere I read that such "local" versions are resolved (by NPM) by placing the 4th party dep in a sub node_modules folder of the lib, which requires it, but I haven't seen this happening.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
  • 1
    Conflicting *non-peer* dependencies are resolved by giving dependencies their own `node_modules/`, but that doesn't happen for *peer* dependencies. It's not straightforward to have multiple versions of React running on the page (although React 17 is aimed at making this easier, see https://reactjs.org/blog/2020/10/20/react-v17.html), for example. You'd have to stick with React 16 until https://github.com/bvaughn/react-virtualized-auto-sizer/pull/35 gets merged (assuming it *does* work with v17, not sure if that's been tested) or ignore the warning. – jonrsharpe Jan 27 '21 at 10:21
  • Great to know that specifically for React. However, is there a general approach to solve this situation? Or is this always a matter of case-by-case? – Mike Lischke Jan 27 '21 at 10:24

0 Answers0