-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[BUG] Peer dependency semver ranges is not respected #2164
Comments
I think this is related to the bug that npm/arborist#182 fixes? |
@ljharb looks like it |
This is not fixed by npm/arborist#182. The issue here is a bit more subtle. This is a class of problem that we don't address currently. Consider a set of dependencies like this:
Then root project, let's say, depends on In order to address this, we'd have to walk all the way back up the dependency chain looking for a path that doesn't eventually lead to While this is theoretically possible, it's also an unbounded graph traversal problem, and NP-hard. And it will often be the case that, even after any arbitrary number of steps, we still have not found a solution, while a prohibitively large search space still remains. I've thought of some heuristics that could be interesting to apply here, in future npm versions, building on the PubGrub algorithm. In a nutshell:
In this case, that would then avoid This is not far off from the algorithm used to resolve audit advisories. But, it's worth noting, doing that audit resolution can be rather costly a lot of the time, which is exactly why we now cache the meta-vulnerability information so extensively. In the meantime, I recommend pinning to a lower version of Closing sadly as "wontfix", but also, "is provably impossible to fix". Sorry. :( |
The new npm7 is installing and resolving peer dependencies automatically, but it looks like it has some bug with resolving dependencies that are in multiple packages. Take a look at this error:
The package.json's dependencies in this example are:
Now,
flex-plugin-scripts
installsflex-plugin-test
which installsenzyme-adapter-react-16
which installsreact-test-renderer
which is requiring[email protected]
.Now, the latest version of react-test-renderer
16.14.0
does have a peerDependency of"react": "^16.14.0"
(I have filed a separate PR on Jest GitHub as their GitHub tags are all messed up - to verify these versions you may want to check the packages by installing them locally; you wouldn't get the right link on GitHub). However, lower versinoedreact-test-renderer
do have a"react": "^16.0.0"
.So
npm
is choosing to install the latest version ofreact-test-renderer
(even though the range is `^16.0.0) which is causing it to install react 16.14.0 which then conflicts with my pinned version.Steps to reproduce
npm install
Environment:
The text was updated successfully, but these errors were encountered: