Can't be installed if Webpack 5 is already a dependency
Closed this issue · 8 comments
- Webpack Version: v4, v5
- Operating System (or Browser): MacOS Monterey
- Node Version: v14.15.4
- webpack-plugin-serve Version: 1.5.0
How Do We Reproduce?
Latest package.json specifies webpack-plugin-ramdisk@^0.1.2
which allows for 0.1.8
to be installed but not 0.2.0
. This has to do with https://semver.org/#spec-item-4 and npm semantic versioning rules.
https://nodejs.dev/learn/semantic-versioning-using-npm
It will only do updates that do not change the leftmost non-zero number
Unlike ramdisk 0.2.0
, 0.1.8
is limited to wepback 4 as a peer dependency and if webpack 5 is already present in the project, the installation results in peer dependency conflict error.
Make sure npm@7.*.*
is used.
Setup a fresh npm project, install webpack, and then install webpack-plugin-serve
mkdir tmp-project
cd tmp-project
npm init -y
npm i webpack -D
npm i webpack-plugin-serve -D
Expected Behavior
webpack-plugin-serve gets installed
Actual Behavior
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: webpack@5.67.0
npm ERR! node_modules/webpack
npm ERR! peer webpack@"^5.1.0" from terser-webpack-plugin@5.3.0
npm ERR! node_modules/terser-webpack-plugin
npm ERR! terser-webpack-plugin@"^5.1.3" from webpack@5.67.0
npm ERR! dev webpack@"^5.67.0" from the root project
npm ERR! 1 more (webpack-plugin-serve)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.20.0" from webpack-plugin-ramdisk@0.1.8
npm ERR! node_modules/webpack-plugin-serve/node_modules/webpack-plugin-ramdisk
npm ERR! webpack-plugin-ramdisk@"^0.1.2" from webpack-plugin-serve@1.5.0
npm ERR! node_modules/webpack-plugin-serve
npm ERR! dev webpack-plugin-serve@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Proposal
If we do actually mean any minor updates by ^0.1.2
it should be changed to 0.*
Thanks for the issue, but please stick to the issue templates for my repos.
Is this an issue with yarn or pnpm?
*
ranges are almost never a good idea unless dealing with internal or monorepo interdependencies. 0.x
ranges can contain breaking changes between minor versions as well. The right fix here is to update the version range to ^0.2.0
@shellscape tried my best to match the issue back to the template, I do apologise to the mess.
Is this an issue with yarn or pnpm?
No it's just regular npm, but v7 specifically, since peer deps are auto installed now, passing --legacy-peer-deps "helps" here, meaning we will not see the issue with npm v6 or lower
I see. As an aside, npm v7 is a mess and it's still slower than pnpm, slower than yarn depending on the dep tree. In short, there's no reason to use npm these days and you're doing yourself and your team a disservice by doing so. give pnpm a look when you have the chance, it ships with Node by default now, just as yarn does.
Got you, going to look into pnpm, thanks for the advice!
Just tried with pnpm and the same steps led to the warning output, but installed the package, apparently this is a npm v7 issue only.
dependencies:
+ webpack-plugin-serve 1.5.0
WARN Issues with peer dependencies found
.
└─┬ webpack-plugin-serve
└─┬ webpack-plugin-ramdisk
└── ✕ unmet peer webpack@^4.20.0: found 5.67.0
Progress: resolved 208, reused 71, downloaded 137, added 137, done
Should we close the issue?
That looks right. I think ilthe issue is still valid, we should update this package.
@shellscape seems like there is a PR fixing exactly this. #233
Closed in #233