-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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've setup a root package with a single workspace, and in that workspace I've installed React and another dependency that has defined a peer dependency on the same version of React. That version of React gets hoisted to the root node_modules and everything works as expected. If I then try to upgrade React, npm will leave that version intact and install the new version in the nested node_modules inside the workspace, leaving the other dependency using the old version of React with seemingly no way to upgrade it.
Expected Behavior
I would expect that when I upgrade the version of React that I installed, that this would update the version in the root node_modules to also be used by other dependencies that have specified React as a peer dependency, rather than installing a separate version in the nested node_modules for the workspace.
Steps To Reproduce
mkdir workspaces-repro
cd workspaces-repro
npm init -y
npm init -y -w packages/package
npm install react@16 react-dom@16 -w package
npm install -D @testing-library/react@12 -w package
# At this point, everything should be using React 16 from the root node_modules
npm ls react
npm install react@17 react-dom@17 -w package
# React 17 has now been installed in the node_modules directory inside of the package workspace, and the testing library package is still using React 16 from the root node_modules
npm ls react
Environment
- npm: 8.8.0
- Node.js: v16.15.0
- OS Name: macOS Monterey 12.3.1
- System Model Name: MacBook Pro
- npm config:
; node bin location = /Users/james.brooks/.nvm/versions/node/v16.15.0/bin/node
; node version = v16.15.0
; npm local prefix = /Users/james.brooks/Desktop/workspaces-repro
; npm version = 8.8.0
; cwd = /Users/james.brooks/Desktop/workspaces-repro
; HOME = /Users/james.brooks
; Run `npm config ls -l` to show all defaults.