Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unable to update peer dependencies in workspaces #4851

Open
2 tasks done
jabrks opened this issue May 3, 2022 · 3 comments
Open
2 tasks done

[BUG] Unable to update peer dependencies in workspaces #4851

jabrks opened this issue May 3, 2022 · 3 comments
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@jabrks
Copy link

jabrks commented May 3, 2022

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.
@jabrks jabrks added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels May 3, 2022
@wraithgar
Copy link
Member

wraithgar commented May 4, 2022

It's [email protected] inside @testing-library/[email protected] that's holding you back. npm update react-dom will fix this situation. npm prioritizes keeping what's there if it already works.

@wraithgar
Copy link
Member

This is still a minor bug, in that it keeps react-dom@16 under @testing-library/[email protected], but at least you have a path to fixing your tree.

@wraithgar wraithgar added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels May 4, 2022
@jabrks
Copy link
Author

jabrks commented May 6, 2022

That seems to have done the trick, thanks for the swift response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

2 participants