Skip to content
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] peerDependency package version doesn't resolve correctly #4958

Closed
2 tasks done
SukkaW opened this issue May 30, 2022 · 4 comments
Closed
2 tasks done

[BUG] peerDependency package version doesn't resolve correctly #4958

SukkaW opened this issue May 30, 2022 · 4 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@SukkaW
Copy link

SukkaW commented May 30, 2022

Is there an existing issue for this?

  • I have searched the existing issues

There are some similar existing issues like #4442 and #4104, don't know if they are related.

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [Redacted]
npm ERR! Found: next@12.1.7-canary.23
npm ERR! node_modules/next
npm ERR!   next@"^12.1.7-canary.23" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer next@">=10.2.0" from eslint-config-next@12.1.7-canary.23
npm ERR! node_modules/eslint-config-next
npm ERR!   dev eslint-config-next@"^12.1.7-canary.23" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Expected Behavior

npm should be able to resolve the dependency tree since eslint-config-next requires a peer dependency of next >= 10.2.0, which 12.1.7-canary.23 does satisfy the constraint.

Steps To Reproduce

$ npm -v
8.11.0
$ mkdir -p npm-issue-peer-deps
$ cd npm-issue-peer-deps
$ npm init -y
$ npm i next@canary eslint-config-next@canary

Environment

  • npm: 8.11.0
  • Node.js: 16.15.0
  • OS Name: macOS 12.4
  • System Model Name: 16.15.0
@SukkaW SukkaW added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels May 30, 2022
@shadowspawn
Copy link
Contributor

shadowspawn commented May 31, 2022

I think this is probably as intended. npm does not include prerelease versions when looking for >= 10.2.0, so 12.1.7-canary.23 is not a candidate.

You can try this out in the semver calculator:
https://semver.npmjs.com

@nlf
Copy link
Contributor

nlf commented May 31, 2022

this is, indeed, intended. prereleases are a bit tricky that way. you might consider taking a look at the docs for overrides to help you force it though!

@SukkaW
Copy link
Author

SukkaW commented Mar 31, 2023

Finally, someone else starts to complaining about the same thing: https://twitter.com/dan_abramov/status/1641574203617943557

so what’s the latest on peer dependencies and unreleased versions? it’s a major PITA.

to recap the situation, we have prerelease React canary versions like "18.3.0-next-12345". and React ecosystem libraries declare compat like "^18" which does not match prereleases.

npm errors.

@SukkaW
Copy link
Author

SukkaW commented Jul 21, 2023

Months later, there is a new victim.

https://twitter.com/NicoloRibaudo/status/1682341361251385345

I'm very confused by how semver works (testing it with https://semver.npmjs.com on @ babel/core).

"^7.25.0 || ^8.0.0-0 <8.0.0" matches 8.0.0-alpha.0 but "^7.22.0 || ^8.0.0-0 <8.0.0" doesn't?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

3 participants