How can someone deal with webpack versions issues « requires a peer of ... but none is installed »?

Viewed 4863

First I receive this error: optimize-css-assets-webpack-plugin@5.0.4 requires a peer of webpack@^4.0.0 then I try with this: npm i optimize-css-assets-webpack-plugin@latest but got that message: terser-webpack-plugin@5.0.3 requires a peer of webpack@^5.1.0

I am seeking for a specific answer to my problem but I think it would be useful also for everyone else to have a general way of thinking about how to deal with similar issues from any other NPM packages

  • I have this general issue as I am trying to use °NEST JS° & °REACT° & °MY TS WORKFLOW° in the same repo...

  • I don't know if I have to drill down each possible dependency tree or If I have to open multiple issues or if I have to take care of these problems myself (alone)...

  • Below trying to get ZERO warning messages installing 3 versions of webpack next@5.0.0-rc.6 lates@5.4.0 and 4@4.44.2

npm install webpack@next # + webpack@5.0.0-rc.6

npm WARN babel-loader@8.1.0 requires a peer of webpack@>=2 but none is installed. You must install peer dependencies yourself.
npm WARN css-loader@5.0.1 requires a peer of webpack@^4.27.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-webpack-plugin@2.2.0 requires a peer of webpack@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN file-loader@6.2.0 requires a peer of webpack@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN html-webpack-plugin@4.5.0 requires a peer of webpack@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN mini-css-extract-plugin@1.3.0 requires a peer of webpack@^4.4.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optimize-css-assets-webpack-plugin@5.0.4 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-loader@4.0.4 requires a peer of webpack@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@10.0.5 requires a peer of webpack@^4.36.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN style-loader@2.0.0 requires a peer of webpack@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN terser-webpack-plugin@5.0.3 requires a peer of webpack@^5.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN url-loader@4.1.1 requires a peer of webpack@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware@3.7.2 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-server@3.11.0 requires a peer of webpack@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-manifest-plugin@2.2.0 requires a peer of webpack@2 || 3 || 4 but none is installed. You must install peer dependencies yourself.
npm WARN workbox-webpack-plugin@6.0.0-alpha.3 requires a peer of webpack@^4.4.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN terser-webpack-plugin@4.2.3 requires a peer of webpack@^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm install webpack@latest # + webpack@5.4.0

npm WARN optimize-css-assets-webpack-plugin@5.0.4 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware@3.7.2 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-manifest-plugin@2.2.0 requires a peer of webpack@2 || 3 || 4 but none is installed. You must install peer dependencies yourself.

npm install webpack@4 # + webpack@4.44.2 

npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN notsup Unsupported engine for watchpack-chokidar2@2.0.0: wanted: {"node":"<8.10.0"} (current: {"node":"15.1.0","npm":"6.14.8"})
npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2@2.0.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN terser-webpack-plugin@5.0.3 requires a peer of webpack@^5.1.0 but none is installed. You must install peer dependencies yourself.


1 Answers

You appear to have an incompatible set of packages. I'm not sure about the syntax, my experience is with composer. If you look though that list you will see most of your packages require either a v4 OR v5:
npm WARN mini-css-extract-plugin@1.3.0 requires a peer of webpack@^4.4.0 || ^5.0.0 ... You have one package that requires a v4 exclusively and another requires a v5 exclusively

npm WARN optimize-css-assets-webpack-plugin@5.0.4 requires a peer of webpack@^4.0.0 ...

npm WARN terser-webpack-plugin@5.0.3 requires a peer of webpack@^5.1.0 ...
Related