[BUG] npm prune doesn't work if multiple packages depend on the same module (but different versions)
Nobody has claimed this yet.
- 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
I have a workspace with foo and bar. Foo depends on react@17 as a dev dep and bar depends on react@16 as a dep. I can npm install just fine, but when I run prune it doesn't remove the react@17 from foo. I've tried many incantations with workspace related flags and whatnot, does not seem to change anything: npm prune --production -ws
Expected Behavior
I would expect that foo's version of react is pruned since it is a dev dep.
Steps To Reproduce
- Make a workspace with two subprojects: foo, bar
npm install react@16 -w barnpm install -D react@17 -w foonpm prune --production -ws- Check node modules and see that react 17 is still there
Environment
- npm: 8.4.0
- Node.js: 16.13.1
- OS Name: OSX
- System Model Name: MacBook Pro
- npm config:
; "user" config from /Users/zach/.npmrc
//registry.npmjs.org/:_authToken = (protected)
yoga-layout:platform = "standalone"
; "env" config from environment
prefix = "/Users/zach/.asdf/installs/nodejs/lts/.npm"
; node bin location = /Users/zach/.asdf/installs/nodejs/16.13.1/bin/node
; cwd = /Users/zach
; HOME = /Users/zach
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 the workspace setup with foo, bar, react@16, and react@17, then run npm prune --production -ws and inspect npm's workspace pruning and dependency-resolution behavior. Done means the dev-only react@17 installation is removed while bar's react@16 dependency remains.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100