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] Could not resolve peerDependencies of matching semver ranges #2999

Closed
Standard8 opened this issue Mar 30, 2021 · 1 comment · Fixed by npm/arborist#266
Closed

[BUG] Could not resolve peerDependencies of matching semver ranges #2999

Standard8 opened this issue Mar 30, 2021 · 1 comment · Fixed by npm/arborist#266
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@Standard8
Copy link
Contributor

Current Behavior:

Using the commands:

mkdir test
npm init
npm install [email protected]

Results in:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/prettier
npm ERR!   peer prettier@">=1.13.0" from [email protected]
npm ERR!   node_modules/eslint-plugin-prettier
npm ERR!     peer eslint-plugin-prettier@"^3.0.1" from [email protected]
npm ERR!     node_modules/eslint-plugin-mozilla
npm ERR!       eslint-plugin-mozilla@"*" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer prettier@"^1.17.0" from [email protected]
npm ERR! node_modules/eslint-plugin-mozilla
npm ERR!   eslint-plugin-mozilla@"*" 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:

I would expect that the modules are installed using prettier matching ^1.17.0. This would be matching the semver range of eslint-plugin-prettier and that of eslint-plugin-mozilla.

From the perspective of an author of eslint-plugin-mozilla, I think the only two choices we have here are:

  1. Match the semver style of eslint-plugin-prettier, i.e. using "prettier": ">=1.17.0.", and "eslint": ">=5.0.0",.
  2. Always ship the latest version of prettier in the peer dependencies.

The first is not sensible for eslint-plugin-mozilla since it depends on ESLint internals, and so we cannot make the same guarantee. I believe it is a reasonable guarantee for eslint-plugin-prettier to make.

The second is also not really viable, as it would break every time a new version of prettier was released until eslint-plugin-mozilla could also be updated.

This may be similar to #2164, but I'm not sure, and I think this points out an addition issue with the way peer dependencies are causing some conflicts between packages.

Steps To Reproduce:

eslint-plugin-mozilla has peer dependencies of:

  "peerDependencies": {
    "eslint-config-prettier": "^6.0.0",
    "eslint-plugin-fetch-options": "^0.0.5",
    "eslint-plugin-html": "^6.0.0",
    "eslint-plugin-no-unsanitized": "^3.1.4",
    "eslint-plugin-prettier": "^3.0.1",
    "eslint": "^7.8.0",
    "prettier": ">=1.13.0"
  },

eslint-plugin-prettier has peer dependencies of:

  "peerDependencies": {
    "eslint": ">=5.0.0",
    "prettier": ">=1.13.0"
  },

The above commands can be used to reproduce this.

Environment:

  • OS: macOS 11.2.3
  • Node: 15.12.0
  • npm: 7.6.3
@Standard8 Standard8 added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Mar 30, 2021
@cawa-93
Copy link

cawa-93 commented Apr 2, 2021

Similar issue with npm v7.8.0

$ npm i vue@^3.0.11

npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: [email protected]
npm ERR! node_modules/vue
npm ERR!   vue@"^3.0.11" from the root project
npm ERR!   peer vue@"^3.0.0" from [email protected]
npm ERR!   node_modules/vue-router
npm ERR!     vue-router@"^4.0.5" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"3.0.10" from @vue/[email protected]
npm ERR! node_modules/@vue/compiler-sfc
npm ERR!   peer @vue/compiler-sfc@"^3.0.6" from @vitejs/[email protected]
npm ERR!   node_modules/@vitejs/plugin-vue
npm ERR!     dev @vitejs/plugin-vue@"^1.2.1" from the root project

At launch, the following packages had already been published:

Workaround for my case:

npm un @vitejs/plugin-vue
npm i vue@^3.0.11
npm i -D @vitejs/plugin-vue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants