-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[BUG] It's not possible to have workspaces with different versions of React #6040
Copy link
Copy link
Closed
Labels
Bugthing that needs fixingthing that needs fixingNeeds Triageneeds review for next stepsneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 releasework is associated with a specific npm 8 release
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
AFAIK It's not possible to have different workspaces with different versions of React due to hoisting.
Expected Behavior
It would be nice to be to have different versions of React in different workspaces, and upgrade different parts of the app at different times
Steps To Reproduce
- create a new npm package with two workspaces
packages/aandpackages/b; itspackage.jsonincludingworkspaces: ["packages/*"] - create a new app in each of the workspaces using
create-react-app - Degrade the version in workspace
adown to 17 by editing itspackage.json - Add a hook in each app, which will error if there are two versions running
- Remove all
node_modulesfolders, delete allpackage-lock.jsonfiles, and runnpm iin the root folder - Start the two apps. This gives the "several versions of react" error with the hooks. Examining the
node_modulesfolder in the root level we see that it contains one of the react versions. - We also tried running
npm iin each of the workspaces separately with the same result
In addition we tried creating a similar setup but without the full app, only installing (different versions of) react and react-dom in the two; still the root level node_modules contains one of them.
Environment
- npm: 8.12.1
- Node.js: v16.13.1
- OS Name: macOS Bug Sur
- System Model Name: Macbook Pro
- npm config:
; "user" config from /Users/[REDACTED]/.npmrc
//registry.npmjs.org/:_authToken = (protected)
access = "public"
; "project" config from /Users/[REDACTED]repos/[REDACTED]/.npmrc
engine-strict = true
; node bin location = /Users/[REDACTED]/.nvm/versions/node/v16.13.1/bin/node
; node version = v16.13.1
; npm local prefix = /Users/[REDACTED]/repos/libry-content
; npm version = 8.12.1
; cwd = /Users/[REDACTED]/repos/[REDACTED]
; HOME = /Users/[REDACTED]
; Run `npm config ls -l` to show all defaults.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Bugthing that needs fixingthing that needs fixingNeeds Triageneeds review for next stepsneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 releasework is associated with a specific npm 8 release