[BUG/REGRESSION] should not install optional peer dependencies
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
Given a project with package A version X installed.
Given a package B having an optional peer dependency on package A version Y.
When installing package B, npm tries to install A version Y. If X and Y are incompatible versions, the install fails.
Additionnaly, the install still fails when explicitly passing --omit=optional.
Expected Behavior
Optional dependencies, including optional peer dependencies, should not be installed, especially when they would cause a conflict with already-installed packages.
Previous discussion
See issue #2615 which was supposed to solve the exact same problem in npm version 7.5.5, apparently the fix has been reverted since then.
Also see broader discussion here, and there.
Steps To Reproduce
- In an Angular project version 21 (at least 21.2.2 reproduces the problem)
- Run
npm install parliamentarch@3.1.0, ornpm install parliamentarch@3.1.0 --omit=optional - See error
Conflicting peer dependency: jsdom@25.0.1
Environment
- OS Name: Windows
- System Model Name: 11
- npm config:
; node version = v24.12.0
; npm version = 11.10.0
; Run `npm config ls -l` to show all defaults.
(private information omitted)
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 install in an Angular 21 project with npm 11.10.0, both with and without --omit=optional, using parliamentarch@3.1.0. Trace why the optional peer dependency on jsdom is resolved despite the omit flag; done means the install completes without conflicting with the already-installed package.
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
- 45/100