-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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] Unable to resolve peer dependency if version contains ">=" #2120
Comments
I have to downgrade |
@RobinWijnant you shouldn't need to do that; but you will need to manually specify |
Hmm.... yeah, so the We do aggressively dedupe peerDeps, so if something else were pulling in a lower version of Eg:
The only way to resolve this would likely be to build up a full pubgrub style ruleset. We sort of approximate such a thing today, but rely on heuristics and nesting to get out of some of the stickiest situations. This also highlights the problem with using Either of these ideas probably merit an RFC though. |
Actually, just preferring a |
I don't believe this should be closed. It currently breaks standard NPM7 installs of several major dependencies, such as for example
I understand that the solution is complex (and I have nothing to contribute myself), but until one is in place it is probably useful to keep this (or a similar) issue open as a reference point for people running into it. On that note, the above is temporarily resolvable by passing the |
Seems like you’re missing a top-level dependency on react-dom (that matches the same minor as react itself). If you fix that, what happens? |
@ljharb yes, it works if I add explicit dependencies at the top level like in npm6, but my understanding was that npm7 resolves and installs peer dependencies in a way that meant this was no longer necessary, sorry if I got this wrong: https://github.com/npm/rfcs/blob/latest/implemented/0025-install-peer-deps.md The problem seems to be that since the peer version of react-dom in this case is |
It’s sometimes no longer necessary, but it’s still always better to be explicit. |
please use the LTS version of node it help me a lot to save my life in peer dependencies tree errors |
You can get the same behavior in npm7 by passing the |
For anyone coming from a web search, in this thread ljharb suggested installing an older version of
For instance, in my project I have react version 16.13.1 installed as listed on my
For me that fixed my issue with installing Edit: you might want to also edit the semantic version for |
You don't need it to be a fixed version; the |
With the |
Fair enough - with react, you probably want to use ~ so that the minors are pinned. |
Ah, thanks I forgot about that good idea.
…On Tue, Mar 16, 2021, 7:27 AM Jordan Harband ***@***.***> wrote:
Fair enough - with react, you probably want to use ~ so that the minors
are pinned.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2120 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGXXPQ3THXJMGTMS3PQTCVDTD5TGLANCNFSM4TJ5WXZA>
.
|
Hi everyone, I have the same problem, I must upgrade the proyect to latest version of NxMonorepo, in this project have a app with next js and react, then next js and react also upgrade: latest version are: "dependencies": { npm ERR! code ERESOLVE any idea how to resolve this, help god please! |
@mauricioross the error is that you’re using testing library react hooks, which requires react 16 or 17 only, and react 18. You either have to downgrade react, or upgrade to a version of the react hooks testing library package that supports react 18. |
@ljharb Surely this can't be the accepted solution - to downgrade React? We have the latest available version of @testing-library/react-hooks and still get that error. Has anyone else looked into this? |
If the latest version of RTL doesn’t say it’s compatible with react 18 (which i doubt) then the only solution is for that package to declare compatibility with react 18. Are you sure there’s not a later version? |
This was what fixed mine, simply installing |
Current Behavior:
When resolving a peer dependency that has a ">=" in it's version, npm uses the latest version of that package to compare with the current dependency version in the package.json.
In this case: npm is looking for react 17, while react 16.13 is also a version that is suits >=16.9.0
Expected Behavior:
npm should be able to resolve the [email protected] peer dependency from @testing-library/[email protected] because [email protected] is a dependency that matches react@>=16.9.0.
Steps To Reproduce:
Environment:
The text was updated successfully, but these errors were encountered: