[BUG] npm i --production deletes duplicate .bin symlinks
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
package.json below:
{
"dependencies": {
"egg-ts-helper": "1.30.3"
},
"devDependencies": {
"egg-bin": "5.1.1"
}
}
installation command:
$ npm i --production
I can't find the egg-ts-helper bin command ets in the node_modules/.bin folder.
This is because egg-bin also provides the ets command, when installation runs in production mode, npm will remove all the devDependencies paths in the node_modules folder, which includes node_modules/.bin/ets, the symlink points toegg-bin/bin/ets.js. See arborist reify here.
Expected Behavior
When running in production mode, and there are duplicated bins provided by both dependencies and devDependencies, npm should keep the dependencies bin.
In the case present above, node_modules/.bin/ets should points to egg-ts-helper/dist/bin.js.
Steps To Reproduce
- Create a blank folder with
package.jsonprovided above; - Install the latest version of npm;
- Run
npm i --production; - Run
ls -la node_modules/.bin; - The result should contain
etssymlink which points toegg-ts-helper/dist/bin.js.
Environment
- npm: 8.13.1
- Node.js: v14.19.1
- OS Name: macOS Big Sur(version: 11.2.3)
- System Model Name:MacBook Pro (16-inch, 2019)
- npm config: the default npm config
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
Reproduce the issue with the package.json and npm i --production steps, then read arborist/reify.js around the linked line 244. Trace how duplicate .bin symlinks are removed in production mode. Done means node_modules/.bin/ets remains and points to egg-ts-helper/dist/bin.js rather than the devDependency target.
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