Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Let's take a simple package.json
{
"name": "untitled",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"react-scripts": "4.0.3",
"worker-loader": "2.0.0"
}
}
react-scripts and worker-loader both have webpack listed in their dependencies or peerDependencies
worker-loader has it listed as
"peerDependencies": {
"webpack": "^3.0.0 || ^4.0.0-alpha.0 || ^4.0.0"
}
react-scripts:
"dependencies": {
"webpack": "4.44.2",
}
The final resolved version of webpack in project's root node_modules will be "4.46.0", and react-scripts will install webpack 4.42.0 in its own node_modules.
If we change peerDependencies of worker-loader to be
"peerDependencies": {
"webpack": "^3.0.0 || ^4.0.0"
}
or change worker-loader version in our root project's package.json to be 3.0.8 (this version has webpack version in peerDependencies listed as as "webpack": "^4.0.0 || ^5.0.0")
In this case, webpack in the project's root directory will be resolved as 4.44.2, and react-scripts won't install another version of webpack in its own node_modules (since 4.44.2 is now shared between two packages)
Expected Behavior
I would expect that in all 3 cases mentioned, webpack should be resolved to 4.44.2 and shared between two packages, or at least the behavior should be consistent.
Steps To Reproduce
- Windows,
npm 8.1.0 or higher (haven't tried on previous versions)
create bare-bone project and follow steps mentioned in "Current behavior"
Environment
- npm: 8.1.0 or higher
- Node.js: 16.12.0
- OS Name: Windows
- System Model Name:
- npm config:
; copy and paste output from `npm config ls` here
; "user" config from C:\Users\mixei.npmrc
msvs_version = "2017"
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\mixei\WebstormProjects\untitled
; HOME = C:\Users\mixei
; Run npm config ls -l to show all defaults.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Let's take a simple
package.jsonreact-scriptsandworker-loaderboth have webpack listed in their dependencies or peerDependenciesworker-loaderhas it listed asreact-scripts:The final resolved version of
webpackin project's root node_modules will be"4.46.0", and react-scripts will install webpack 4.42.0 in its own node_modules.If we change peerDependencies of worker-loader to be
or change worker-loader version in our root project's package.json to be 3.0.8 (this version has webpack version in peerDependencies listed as as
"webpack": "^4.0.0 || ^5.0.0")In this case, webpack in the project's root directory will be resolved as 4.44.2, and react-scripts won't install another version of webpack in its own node_modules (since 4.44.2 is now shared between two packages)
Expected Behavior
I would expect that in all 3 cases mentioned, webpack should be resolved to 4.44.2 and shared between two packages, or at least the behavior should be consistent.
Steps To Reproduce
npm 8.1.0or higher (haven't tried on previous versions)create bare-bone project and follow steps mentioned in "Current behavior"
Environment
; copy and paste output from `npm config ls` here; "user" config from C:\Users\mixei.npmrc
msvs_version = "2017"
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\mixei\WebstormProjects\untitled
; HOME = C:\Users\mixei
; Run
npm config ls -lto show all defaults.