【问题标题】:How can someone deal with webpack versions issues « requires a peer of ... but none is installed »?有人如何处理 webpack 版本问题«需要...但没有安装的对等»?
【发布时间】:2021-02-20 08:58:36
【问题描述】:

首先我收到这个错误:optimize-css-assets-webpack-plugin@5.0.4 requires a peer of webpack@^4.0.0,然后我尝试这个:npm i optimize-css-assets-webpack-plugin@latest,但得到了那个消息:terser-webpack-plugin@5.0.3 requires a peer of webpack@^5.1.0

我正在为我的问题寻找一个具体的答案,但我认为对其他人有一个通用的方式来思考如何处理任何其他 NPM 包中的类似问题也是有用的

  • 当我尝试在同一个 repo 中使用 °NEST JS° 和 °REACT° 和 °MY TS WORKFLOW° 时,我遇到了这个一般性问题...

  • 我不知道我是否必须深入研究每个可能的依赖关系树,或者我是否必须打开多个问题,或者我是否必须自己(一个人)处理这些问题...

  • 下面试图获得零警告消息安装 3 个版本的 webpack next@5.0.0-rc.6 lates@5.4.04@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.


【问题讨论】:

  • npm@7 似乎已经修复了所有的错误信息
  • npm@7 自动安装 peerdependancy,所以你不会看到这个错误,但这不是解决这个错误的方法
  • 刚刚出现这个问题,并且能够通过删除 package-lock.jsonnode_modules 并再次运行 npm i 来解决它。

标签: node.js npm webpack versioning dependency-management


【解决方案1】:

您似乎有一组不兼容的软件包。我不确定语法,我的经验是作曲家。如果您查看该列表,您会发现您的大多数软件包都需要 v4 OR v5:
npm WARN mini-css-extract-plugin@1.3.0 requires a peer of webpack@^4.4.0 || ^5.0.0 ... 您有一个包只需要 v4,而另一个包只需要 v5

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 ...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-04
    • 2017-12-18
    • 2021-01-26
    • 1970-01-01
    • 1970-01-01
    • 2016-12-07
    • 1970-01-01
    相关资源
    最近更新 更多