This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
Allow --force to override conflicted peerOptional #228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on #227, land that first.
With a dependency graph like this:
We do not install the peerOptional dependency by default, so even though
b@2
is included in the peerSet ofa
, it is not added to the tree.Then, the
b@1
dependency is added to satisfy root's direct dependencyon it, causing the
a -> b@2
edge to become invalid.We then try to resolve the
a -> b@2
edge, and find that we cannotplace it anywhere, causing an
ERESOLVE
error.However, because
b@2
is no longer a part of a peerSet sourced on theroot
node, we miss the chance to detect that it should be overridden,resulting in an
ERESOLVE
failure even when--force
is used.This commit adds the check for
this[_force]
prior to crashing withERESOLVE, so that cases that avoid our earlier heuristics still accept
the invalid resolution when
--force
is in effect.Fix: #226
Fix: npm/cli#2504