[BUG] npm install silently fails to install peer 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 doesn't install peer dependency @mdx-js/react without any error or even warning. Warning is printed out only after installation when using npm ci and and in such case @mdx-js/react is also not installed:

This happens because npm installs the latest version of React instead version required by dependencies. Such behaviour can be avoided by adding required version of React within package.json. The only reference to a new version of React I found is in library @figspec/react in devDependencies what shouldn't impact.
This issue can be reproduced with the following versions of npm: 8.19.2, 8.19.3, 9.2.0.
package.zip
Expected Behavior
npm should not install the latest version of React but one which is required by dependencies or npm should throw an error when library is not installed.
Steps To Reproduce
- In this environment with the latest version of node and npm
- With this attached package.json
- Run 'npm i'
- See node_modules and look for @mdx-js/react
- Run 'npm ci'
- See warning mesages about problems with resolving dependencies with @mdx-js/react
- See node_modules and look for @mdx-js/react
Environment
- npm: 9.2.0
- Node.js: 19.4.0
- OS Name: Microsoft Windows [Version 10.0.19044.2486]
- System Model Name: Asus G551JM
- npm config:
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\Radosław\\AppData\\Roaming\\npm"
; "cli" config from command line options
location = "project"
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v19.4.0
; npm local prefix = C:\_projects\test-npm
; npm version = 9.2.0
; cwd = C:\_projects\test-npm
; HOME = C:\Users\Radosław
; Run `npm config ls -l` to show all defaults.
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 with the attached package.json from package.zip and reproduce the behavior using npm i and npm ci on the reported Node.js and npm versions. Trace the peer-dependency resolution path responsible for @mdx-js/react and compare the installed dependency tree and warnings; done means the dependency is installed or a clear error is reported consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100