[BUG] Unable to install untracked peer optional dependency
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
npm i <dependency name> succeeds with exit code 0 but the resultant dependency is not present, if <dependency name> is an untracked (not included in prod or dev dependencies) optional peer dependency.
I believe this is caused by https://github.com/npm/cli/pull/8431.
Expected Behavior
npm i <dependency name> should always install the dependency if the dependency has no version incompatibility issues.
Steps To Reproduce
Easiest way to see this is working in the mongodb package, because this scenario arose in our CI.
- Clone node-mongodb-native.
- run
npm i - install
kerberos:npm i kerberos - attempt to use kerberos: `node -p "require('kerberos')":
node:internal/modules/cjs/loader:1408
throw err;
^
Error: Cannot find module 'kerberos'
Environment
- npm: 11.5.0+
- Node.js: doesn't matter
- OS Name: doesn't matter
- System Model Name: doesn't matter
- npm config: doesn't matter
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 in the node-mongodb-native package by running npm i, then npm i kerberos, followed by node -p "require('kerberos')". Trace npm 11.5.0's dependency installation and optional peer handling; done means an untracked optional peer dependency is present and can be required when no version incompatibility exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100