将我们的生态系统迁移到 Node 22
2025 年初,Electron 的 npm 生态系统代码库(位于 @electron/
和 @electron-forge/
命名空间下)将迁移到 Node.js 22,作为最低支持版本。
¥In early 2025, Electron’s npm ecosystem repos (under the @electron/
and @electron-forge/
namespaces) will move to Node.js 22 as the minimum supported version.
这意味着什么?
¥What does this mean?
过去,Electron npm 生态系统中的软件包(Forge、Packager 等)会尽可能长时间地支持 Node 版本,即使某个版本已达到其生命周期结束 (EOL) 日期。这样做是为了确保我们不会分裂生态系统 - 我们理解许多项目依赖于旧版本的 Node,除非有迫切的升级理由,否则我们不想冒险搁浅这些项目。
¥In the past, packages in Electron’s npm ecosystem (Forge, Packager, etc) have supported Node versions for as long as possible, even after a version has reached its End-Of-Life (EOL) date. This is done to make sure we don’t fragment the ecosystem—we understand that many projects depend on older versions of Node, and we don’t want to risk stranding those projects unless there was a pressing reason to upgrade.
随着时间的推移,使用 Node.js 14 作为我们的最低版本变得越来越困难,原因如下:
¥Over time, using Node.js 14 as our minimum version has become increasingly difficult for a few reasons:
-
由于缺乏官方的 Node.js 14 macOS ARM64 版本,我们需要维护持续集成 (CI) 基础设施解决方案,以提供全面的测试覆盖。
¥Lack of official Node.js 14 macOS ARM64 builds requires us to maintain CI infrastructure workarounds to provide full test coverage.
-
engines
对上游软件包依赖的要求已提前,这使得解决依赖冲突带来的供应链安全问题变得越来越困难。¥
engines
requirements for upstream package dependencies have moved forward, making it increasingly difficult to resolve supply chain security issues with dependency bumps.
此外,Node.js 的新版本包含许多我们希望利用的改进,例如运行时原生的通用实用程序(例如 fs.glob
和 util.parseArgs
)以及全新的内置电池模块(例如 node:test
、node:sqlite
)。
¥Additionally, newer versions of Node.js have included many improvements that we would like to leverage, such as runtime-native common utilities (e.g. fs.glob
and util.parseArgs
) and entire new batteries-included modules (e.g. node:test
, node:sqlite
).
为什么现在升级?
¥Why upgrade now?
2024 年 7 月,Electron 生态系统工作组决定将所有软件包升级到最早的 Node 版本,该版本将支持同步 ESM 图的 require()
。 (参见 nodejs/node#51977 和 nodejs/node#53500)在该版本达到其 LTS 日期之后的未来时间点。
¥In July 2024, Electron’s Ecosystem Working Group decided to upgrade all packages to the earliest Node version where require()
of synchronous ESM graphs will be supported (see nodejs/node#51977 and nodejs/node#53500) at a future point after that version reaches its LTS date.
我们决定将更新时间定为 2025 年 1 月/2 月。此次升级后,Node 22 将成为现有生态系统软件包中支持的最低版本。
¥We’ve decided to set that update time to January/February 2025. After this upgrade occurs, Node 22 will be the minimum supported version in existing ecosystem packages.
我需要采取什么措施?
¥What action do I need to take?
我们将尽可能地保持兼容性。但是,为了确保获得最佳支持,我们建议你将应用升级到 Node 22 或更高版本。
¥We’ll strive to maintain compatibility as much as possible. However, to ensure the best support, we encourage you to upgrade your apps to Node 22 or higher.
请注意,你项目中运行的 Node 版本与你当前 Electron 版本中嵌入的 Node 版本无关。
¥Note that the Node version running in your project is unrelated to the Node version embedded into your current version of Electron.
下一步是什么
¥What's next
如果你有任何问题或疑虑,请随时写信至 info@electronjs.org 。你还可以在我们的官方 Electron Discord 中找到社区支持。
¥Please feel free to write to us at info@electronjs.org if you have any questions or concerns. You can also find community support in our official Electron Discord.