[BUG] Installing package with optional peer dependencies reports conflicts incorrectly
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'm using optional peer dependencies for maintaining the 3DTilesRenderer package to ensure only the dependencies that users need are installed. As far as I can tell there are no conflicts within the peer dependency definitions but when installing from npm in a new project via npm install 3d-tiles-renderer I get the following error:
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: test@1.0.0
npm error Found: react@19.1.0
npm error node_modules/react
npm error peer react@"*" from expo@53.0.17
npm error node_modules/expo
npm error peerOptional expo@">=43.0" from @react-three/fiber@8.18.0
npm error node_modules/@react-three/fiber
npm error peerOptional @react-three/fiber@"^8.17.9" from 3d-tiles-renderer@0.4.11
npm error node_modules/3d-tiles-renderer
npm error 3d-tiles-renderer@"*" from the root project
npm error peer expo@"*" from @expo/dom-webview@0.1.5
npm error node_modules/@expo/dom-webview
npm error peerOptional @expo/dom-webview@"*" from expo@53.0.17
npm error 3 more (expo-asset, expo-file-system, expo-gl)
npm error peer react@"*" from @expo/dom-webview@0.1.5
npm error node_modules/@expo/dom-webview
npm error peerOptional @expo/dom-webview@"*" from expo@53.0.17
npm error 5 more (react-native, react-native-webview, expo-asset, expo-gl, react-native-web)
npm error
npm error Could not resolve dependency:
npm error peerOptional react@"^18.3.1" from 3d-tiles-renderer@0.4.11
npm error node_modules/3d-tiles-renderer
npm error 3d-tiles-renderer@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
When specifying the same packages as "dependencies" in the same package.json, though, and installing them there are no conflicts. So it seems the optional peer dependencies are being reported incorrectly.
Expected Behavior
No errors should be reported when installing a package with optional peer dependencies when there are no conflicts. It's not clear to me why conflicts are being checked at all when the project has not separately installed the peer dependencies.
Steps To Reproduce
- Create a new folder
- Run
npm init - Run
npm install 3d-tiles-renderer - See error reporting conflicts even though no other packages are installed and the package has no required dependencies other than 1 peer dependency (three.js) which has no dependencies itself.
Environment
- npm: 11.4.2
- Node.js: 24.3.0
- OS Name: Sequoia 15.5
- System Model Name: 2021 M1 Macbook Pro
- npm config:
; "user" config from /Users/garrett/.npmrc
//registry.npmjs.org/:_authToken = (protected)
; node bin location = /Users/garrett/.nvm/versions/node/v24.3.0/bin/node
; node version = v24.3.0
; npm local prefix = /Users/garrett/Desktop/test
; npm version = 11.4.2
; cwd = /Users/garrett/Desktop/test
; HOME = /Users/garrett
; 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
Reproduce the report with npm 11.4.2 and Node.js 24.3.0 by creating an empty project and running npm install 3d-tiles-renderer; compare this with declaring the same packages as dependencies. Trace npm's peer-dependency resolution for the package's optional peer dependencies, and consider the work complete when the reproduction installs without a false conflict while genuine conflicts remain reported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100