[BUG] Could not resolve dependency when using carrat ranges
Open
Nobody has claimed this yet.
Bug
Needs Triage
Release 9.x
- 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
Given a monorepo with using npm workspaces and the following layout
application/
- name: "my-application"
- version: "1.4.5"
- dependencies:
- @foo/A: "^1.3.2"
- @foo/B: "^6.10.2"
packages/
a/
- name: "@foo/A"
- version: "1.3.2"
- peerDependencies:
- @foo/B: ^6.7.0
b/
- name: "@foo/B"
- version: "6.10.2"
And if I run npm i due to needing to resolve conflicts in my package-lock.json or when I need to create my package-lock.json from scratch then I get the following error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @foo/A@1.3.2
npm ERR! Found: peer @foo/b@"^6.7.0" from @foo/A@1.3.2
npm ERR! packages/a
npm ERR! @foo/A@1.3.2
npm ERR! node_modules/@foo/A
npm ERR! workspace packages/a from the root project
npm ERR! 1 more (lens-desktop)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @foo/b@"^6.7.0" from @foo/A@1.3.2
npm ERR! packages/a
npm ERR! @foo/A@1.3.2
npm ERR! node_modules/@foo/A
npm ERR! workspace packages/a from the root project
npm ERR! 1 more (lens-desktop)
npm ERR!
npm ERR! Conflicting peer dependency: @foo/b@6.10.2
npm ERR! node_modules/@foo/b
npm ERR! peer @foo/b@"^6.7.0" from @foo/A@1.3.2
npm ERR! packages/a
npm ERR! @foo/A@1.3.2
npm ERR! node_modules/@foo/A
npm ERR! workspace packages/a from the root project
npm ERR! 1 more (lens-desktop)
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
Given that 6.10.2 is compatible with ^6.7.0 this should install without any errors.
Environment
- npm: 9.8.0
- Node.js: v16.20.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing npm i with the described npm workspaces layout using npm 9.8.0 and Node.js 16.20.0. Verify that the workspace dependency at 6.10.2 is accepted for the peer range ^6.7.0 without requiring --force or --legacy-peer-deps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100