Skip to main content

将我们的生态系统迁移到 Node 22

· 4 min read

在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) 基础设施解决方案,以提供全面的测试覆盖。
  • engines 对上游软件包依赖的要求已经向前推进,这使得通过升级依赖来解决供应链安全问题变得越来越困难。

此外,较新的 Node.js 版本包含了许多我们希望利用的改进,例如运行时原生的常用工具(如 fs.globutil.parseArgs)以及全新的内置模块(如 node:testnode: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的生态系统工作组决定将所有包升级到支持同步ESM图的最早Node版本(参见nodejs/node#51977nodejs/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 年一月/二月。在此次升级之后,节点 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.