npm / npm/cli

[BUG] install order affects correctness of peerDependencies resolution

Open
#8,492 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

Peer dependencies written to package.json:

"ag-grid-community": "^34.1.1",
"ag-grid-enterprise": "^34.1.1",
"ag-grid-react": "^34.1.1"

versions resolved in package-lock.json:

"node_modules/ag-grid-community": {
  "version": "34.1.1",
},
"node_modules/ag-grid-enterprise": {
  "version": "34.1.1",
},
"node_modules/ag-grid-react": {
  "version": "34.1.1",
}
Expected Behavior

Peer dependencies written to package.json:

"ag-grid-community": "^34.0.2",
"ag-grid-enterprise": "^34.0.2",
"ag-grid-react": "^34.0.2"

versions resolved in package-lock.json:

"node_modules/ag-grid-community": {
  "version": "34.0.2",
},
"node_modules/ag-grid-enterprise": {
  "version": "34.0.2",
},
"node_modules/ag-grid-react": {
  "version": "34.0.2",
}
Steps To Reproduce
  1. Having package like below, lets call it tab
{
  "name": "tab",
  "peerDependencies": {
    "ag-grid-community": "~34.0.2",
    "ag-grid-enterprise": "~34.0.2",
    "ag-grid-react": "~34.0.2",
  }
}
  1. In host app project, we would like to install tab, and required peerDependencies and more
  2. Run npm install tab random-package ag-grid-community ag-grid-enterprise ag-grid-react --save
  3. See invalid packages being installed (see Current Behavior)

Console output:

npm warn Unknown project config "email". This will stop working in the next major version of npm.
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: app@1.0.0
npm warn Found: ag-grid-community@34.0.2
npm warn node_modules/ag-grid-community
npm warn   ag-grid-community@"*" from the root project
npm warn   3 more (tab, ag-grid-enterprise, ag-grid-react)
npm warn
npm warn Could not resolve dependency:
npm warn peer ag-grid-community@"~34.0.2" from tab@7.45.0
npm warn node_modules/tab
npm warn   tab@"*" from the root project
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: app@1.0.0
npm warn Found: ag-grid-enterprise@34.0.2
npm warn node_modules/ag-grid-enterprise
npm warn   ag-grid-enterprise@"*" from the root project
npm warn   1 more (tab)
npm warn
npm warn Could not resolve dependency:
npm warn peer ag-grid-enterprise@"~34.0.2" from tab@7.45.0
npm warn node_modules/tab
npm warn   tab@"*" from the root project
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: app@1.0.0
npm warn Found: ag-grid-react@34.0.2
npm warn node_modules/ag-grid-react
npm warn   ag-grid-react@"*" from the root project
npm warn   1 more (tab)
npm warn
npm warn Could not resolve dependency:
npm warn peer ag-grid-react@"~34.0.2" from tab@7.45.0
npm warn node_modules/tab
npm warn   tab@"*" from the root project
  1. Now, clear package.json, remove package-lock.json and remove node_modules
  2. Run, note order changed, tab is next to ag-grid-* npm install tab ag-grid-community ag-grid-enterprise ag-grid-react random-package --save
  3. Get expected result 🙏 (see Expected Behavior)

Console output:

npm warn Unknown project config "email". This will stop working in the next major version of npm.
Environment
  • npm: 11.5.2
  • Node.js: v22.18.0
  • OS Name: macOS 15.6
  • System Model Name: MacBook Pro 14-inch, Nov 2023
  • npm config:
; copy and paste output from `npm config ls` here

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two npm install commands from the issue using package.json, package-lock.json, and the tab peerDependencies example, then compare the resolved versions and warnings. Trace the npm install peer-dependency resolution entry points to determine why argument order changes the result; done means both orders resolve the requested ag-grid versions consistently without ERESOLVE warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.