“webpack-concat-text-plugin”与”node”不兼容。

huangapple go评论73阅读模式
英文:

webpack-concat-text-plugin "node" is incompatible

问题

The concat-text-webpack-plugin插件嵌套在某个包内,在我使用NextJS和Node 18时出现错误。

错误 concat-text-webpack-plugin@0.2.1:引擎 "node" 与此模块不兼容。期望版本 ">=8 <=16"。实际版本 "18.16.0"
错误:发现不兼容的模块。

它与Node 16兼容。查看包代码时,有一行

"engines": {
    "node": ">=8 <=16"
},

这会阻止使用Node 18+。该存储库已存档,无法进行PR。

如何在Node 18+中使用它?

英文:

The concat-text-webpack-plugin is nested deep in some package, and errors when I have NextJS and Node 18.

error concat-text-webpack-plugin@0.2.1: The engine &quot;node&quot; is incompatible with this module. Expected version &quot;&gt;=8 &lt;=16&quot;. Got &quot;18.16.0&quot;
error Found incompatible module.

It's fine with Node 16. Looking into the package code there is a line

&quot;engines&quot;: {
    &quot;node&quot;: &quot;&gt;=8 &lt;=16&quot;
},

which blocks using Node 18+. The repo is archived and cannot be PR'd.

How can I use this with Node 18+?

答案1

得分: 1

这让我深入了解了一些细节,我成为了一个更好的开发者。我分叉了这个仓库,并重新编写了测试以适应Node 18+和Webpack 5。这些测试依赖于Webpack的一些棘手行为,但这些行为已经在v4 => v5中被完全移除。

我在这里发布了一个包:https://www.npmjs.com/package/concat-text-webpack-plugin-2023

关键部分是,原始包通常是一个嵌套的依赖项。这个新版本与原始版本具有相同的API,并包含了关于如何使解析与嵌套依赖项一起工作的README。

英文:

This lead me down a rabbit hole and I have come out a much better developer. I forked the repo, and rewrote the tests to work with Node 18+ and Webpack 5. The tests relied on some knarly behaviour of webpack which was completely removed from v4 => v5.

I published a package here https://www.npmjs.com/package/concat-text-webpack-plugin-2023

The key bit is that the original package is regularly a nested dependency. This new version has the same API as the original and has included README on how to make the resolutions work with nested deps.

答案2

得分: 1

以下是翻译好的部分:

对于我来说,这个错误是因为以下原因产生的:

  1. serverless-bundle 要求使用 concat-text-webpack-plugin。
  2. 我正在运行一个过时的 serverless-bundle 版本。

Serverless bundle 在 6.0 版本中 解决了这个问题,所以为了解决这个问题,我运行了 yarn upgrade serverless-bundle@6,这会移除不良的依赖项,并允许我升级到 node 18。

由于 serverless-bundle 非常受欢迎,这个解决方案很可能适用于大多数人。如果你的代码库通过其他包包含了 concat-text-webpack-plugin,你可以通过运行 yarn why concat-text-webpack-plugin 来找到问题的根本原因,这将显示导致此依赖关系的顶级包。然后,你很可能可以升级顶级包。

英文:

For me, this error came from the fact that:

  1. concat-text-webpack-plugin was required by serverless-bundle
  2. I was running an outdated version of serverless-bundle

Serverless bundle resolved this in the 6.0 release, so to solve this in my codebase, I ran yarn upgrade serverless-bundle@6 which removed the bad dependency and allowed me to upgrade to node 18.

Since serverless-bundle is very popular, it's likely this solution will work for most people. If your codebase includes concat-text-webpack-plugin through some other package, you can find the culprit by running yarn why concat-text-webpack-plugin which will show the top-level package causing this dependency. You can then most likely upgrade the top level package.

huangapple
  • 本文由 发表于 2023年5月15日 01:26:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76248820.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定