🌐 Nodejs.cn
announcements

Express@5.1.0:现在在 npm 上的默认版本,带有 LTS 时间表

Express Technical CommitteeMarch 31, 2025

Express v5.0.0 于去年 9 月 9 日发布,但我们并没有在 npm 上将其标记为 latest 版本。很多人问我们为什么以及什么时候会发布,坦率地说,当时我们还没有准备好做出这个跳跃。如果你在过去一年没有关注项目的动态,我们一直在努力振兴该项目,当我们推出初始 v5 版本时,仍有许多未解决的问题。因此,首先让我们快速回顾一下其中一些未解决的问题。

🌐 Express v5.0.0 was released on September 9th last year, but we didn’t make it the latest release on npm. Many asked us why and when it would be, and frankly we were not ready at the time to take that jump. If you have not followed the news from the project this past year, we have been hard at work reviving the project and when we pushed the initial v5 release there were many loose ends still hanging. So first lets quickly go over some of those loose ends.

文档更新

🌐 Documentation updates

我们很长一段时间没有更新文档,提供迁移指南,甚至没有完全审核一些停滞的 v4/5 文档。从那以后,我们有大量优秀的贡献者帮助我们将事情整理得更好。和任何基于志愿者的开源项目一样,我们非常欢迎贡献来帮助我们改进,因此在你升级时,请继续提交 PR 来修复我们遗漏的任何内容。

🌐 We had not updated the docs, provided migration guides, or even fully reviewed some of the stagnated v4/5 docs in a long time. Since then we have had tons of great contributors help get things into better shape. As with any volunteer based Open Source project, we love contributions to help us improve so as you upgrade please continue to open PRs to fix anything we missed.

你可以在我们的网站上找到我们的v5 文档和我们的迁移指南

🌐 You can find our v5 docs and our migration guide on the website.

迁移支持

🌐 Migration Support

我们知道版本之间的迁移可能具有挑战性,特别是当它涉及像 Express 这样广泛使用的框架的重大变更时。这就是为什么我们致力于开发一个解决方案,以简化部分流程并减少对开发者的影响。

🌐 We know that migrating between versions can be challenging, especially when it involves significant changes in a widely used framework like Express. That’s why we have worked on a solution to simplify part of the process and reduce the impact on developers.

感谢 SebastianFilip 的巨大努力,我们开发了一个新的 codemod 包,专门用于简化从 Express v4 升级到 v5 以及未来主要版本的过渡。该包自动化了许多必要的代码更改,最大限度地减少了手动操作,使升级尽可能顺利和高效。

🌐 Thanks to the incredible efforts of Sebastian and Filip, we have developed a new codemod package specifically designed to facilitate the transition from Express v4 to v5, as well as future major versions. This package automates many of the necessary code changes, minimizing manual effort and making the upgrade as smooth and efficient as possible.

然而,我们理解并非所有更改都可以自动化。一些破坏性更改,例如 新的路径路由匹配语法,需要开发者手动修改。你可以在我们的 原始发布公告 中阅读有关 v5 带来的所有破坏性更改的更多信息。

🌐 However, we understand that not all changes can be automated. Some breaking changes, such as the new Path Route Matching syntax, require manual modifications by developers. You can read more about all of the breaking changes which came with v5 in our original release announcement.

有关迁移过程的更多详细信息以及如何使用 codemod 包,请查看仓库的自述文件迁移指南

🌐 For more details on the migration process and how to use the codemod package, check the repository’s README and the migration guide.

生态系统兼容性

🌐 Ecosystem compatibility

Express生态系统是其最强大的资源之一。它可以追溯到Node.js的早期时期,是保持Express流行的支柱。当它经历了10年没有重大版本发布时,从中间件到文档的所有内容都需要更新。我们希望确保大家有时间将所有内容更新完毕,然后再让每个人迁移过去。尤其是,我们关心那些非常多的大型初学者用户群,他们可能不知道自己正在阅读的博客文章与他们从npm i express获得的内容不兼容。

🌐 The Express ecosystem is one of its strongest assets. It goes back to the early days of Node.js and is the backbone that keeps express popular. When it goes 10 years without a major release everything from middleware to documentation needed updates. We wanted to make sure folks had some time to get all of that updated before we had everyone moving over. Particularly we care about our very large beginner user base who may not know the blog post they are reading is not compatible with what they get from npm i express.

我们认识到在重大升级过程中一些摩擦是不可避免的,但多亏了像 NestJS 的 Kamil 这样的生态系统合作伙伴的工作 在我们进行 latest 之前更新 express,我们有望走在前列。正如我上面所说,我们始终欢迎帮助,使这次过渡对后续的人更加顺利,提交 PR 是你能提供的最佳支持。

🌐 We recognize that some friction is inevitable during major upgrades, but thanks to work from ecosystem partners like Kamil from NestJS working to update express before we went latest we will hopefully be ahead of the curve. And as I said above, we always welcome help to make this transition easier for those who follow after you, PRs are the best support you can give.

长期支持

🌐 Long Term Support

我们一直在讨论在 v5 发布后如何支持 v4,但我们尚未制定明确的指导方针或期望,而且我们在这里的计划也没有(仍然没有)面向终端用户的文档。虽然我们在这方面还有进展空间,但我们有一个拟议的长期支持策略,这将成为我们即将发布的文档的基础。非常欢迎大家提出意见,这样我们可以确保信息清晰传达,并且为社区所接受。

🌐 We had been discussing how to support v4 now that v5 was out, but we had not defined a clear guideline or expectation, and we had (still don’t have) end user docs on our plans here. While we still have progress to make here, we have a proposed LTS strategy which will be the basis for our forthcoming docs. Input is very welcome on this so we can make sure it is clearly communicated and acceptable to the community.

此外,自那时起我们已宣布与 HeroDevs 建立合作伙伴关系,以帮助那些在更新方面能力较弱的公司。关于 v4 生命周期结束时该如何运作的更多信息将在我们接近那个时间时公布。

🌐 Additionally since then we have announced a partnership with HeroDevs to help companies who are less capable of updating. More information on how this will work when v4 EOL will come when we get closer to that time.


支持阶段和更新至最新

🌐 Support Phases and Going latest

“go latest”是什么意思?如果你不熟悉 npm dist-tags 的工作方式,latest 标签就是用户在运行 npm install express 时会得到的版本。这很重要,因为这意味着它是“默认安装版本”,并且会触发近 1700 万每周下载量从我们当前的最新版本 v4.21.2 过渡到 v5。在我们开始这一过渡时,我们希望用户、公司和其他组织明确知道这对支持意味着什么。为此,我们制定了一个 LTS 策略,该策略定义了我们的 3 个支持阶段,并设定了 v4 进入生命周期结束(EOL)的目标日期。

🌐 What does it mean to “go latest”? If you are unfamiliar with how npm dist-tags work, the latest tag is what users will get when they run npm install express. This is important because it means it is the “default installed version” and will trigger the transition of nearly 17 million weekly downloads from our current latest v4.21.2 to v5. As we start this transition we want users, companies, and other organizations to know exactly what it means for support. To help with this we have developed an LTS strategy which defines our 3 support phases and set’s target dates for when v4 will enter EOL.

Express 主要版本将经历三个支持阶段:

🌐 Express major versions will go through three supported phases:

  • CURRENT:一个新的主要版本在发布时被指定为 CURRENT。它可用,但在 npm 上至少 3 个月内不是 latest 版本。
  • ACTIVE:在至少三个月的时间之后,并且 TC 同意它是稳定且安全的,ACTIVE 版本将在 npm 上以 latest 标签发布至少 12 个月。
  • MAINTENANCE:当一个新的主要版本变为 ACTIVE 时,之前的主要版本将进入 MAINTENANCE 状态,为期 12 个月。

当前

🌐 CURRENT

  • 新的主要版本将经历一个短期的强化阶段,以确保稳定性、安全性以及生态系统库/资源的兼容性。
  • 我们将努力确保不包含破坏性更改,但保留在此期间进行破坏性安全或高优先级修复的权利。
  • CURRENT 行将接收所有类型的主动工作,包括:错误修复、安全补丁、新功能和废弃通知。
  • 建议用户使用 CURRENT 系列,并根据自己的风险状况尽快升级

活跃

🌐 ACTIVE

  • ACTIVE 行将接收所有类型的主动工作,包括:错误修复、安全补丁、新功能和废弃通知。
  • 对于用户来说,ACTIVE 版本被认为是在任何给定时间最稳定且支持最完善的版本。

维护

🌐 MAINTENANCE

  • MAINTENANCE 线路只会接收安全补丁或高优先级的错误修复。
  • 强烈建议用户升级到 CURRENTACTIVE 版本。

拟议时间表

🌐 Proposed Schedule

对于现有的发布线路,我们将设置以下阶段日期:

🌐 For the existing release lines, we will set the following phase dates:

主版本当前活跃维护结束支持
4.x2025-04-01*不早于 2026-10-01
5.x2024-09-112025-03-31**不早于 2026-04-01**不早于 2027-04-01
6.x***不早于 2026-01-01

正如你所看到的,这意味着 v5.1.0 被标记为 latest 表示我们从 CURRENT 移动到 ACTIVE,这通过将 v4 移动到 MAINTENANCE 来启动其生命周期终止(EOL)的计时。我们认识到 v4 是一个特殊情况,因为它在 Node.js 的大部分历史中都是唯一的主要版本。正因为如此,我们希望保持灵活性,同时也提供更长一些的支持。我们希望为生态系统做最好的事,所以请将这些目标视为方向,而非承诺。

🌐 As you can see, this means that v5.1.0 being tagged latest indicates that we moved from CURRENT to ACTIVE which starts the clock on EOL for v4 by moving it to MAINTENANCE. We recognize that v4 is a special case having been the only major version for most of the history of Node.js itself. Because of this, we want to remain flexible and also provide a bit longer support. We want to do what is best for the ecosystem, so consider these goals not commitments.

*: v4 是一种特殊情况,我们可能会延长维护支持
**: v5 的维护和生命周期结束日期由 v6 发布的时间决定,这些日期反映了如果我们在 2025-10-01 发货 v6 的最早日期
*** : v6 的工作尚未正式开始,这只是根据我们拟议的政策可以发货的最早日期


最后,v5.1.0 中发生了什么变化

🌐 Finally, what changed in v5.1.0

此版本主要集中在由于支持许多旧的 Node.js 版本而产生的技术债务,以及其他一些停滞的事情,这些事情在 v5.0.0 发布之前尚未完成。

🌐 This release primarily focused on tech debt from supporting so many old Node.js versions and other things that stagnated but were not landed before v5.0.0 went out.

Express 5.1.0 主要变化

🌐 Express 5.1.0 Main Changes

  • res.send() 中添加对 Uint8Array 的支持
  • 将所有剩余的依赖转换为使用 ^ 范围,而不是固定版本
  • 在 package.json 中添加 funding 字段以高亮我们的 OpenCollective
  • res.sendFile() 中添加了对 ETag 选项的支持
  • 添加了对使用 res.links() 添加具有相同 rel 的多个链接的支持
  • 性能:使用循环处理 acceptParams
  • 参见 [Changelog v5.1.0](https://github.com/expressjs/express/releases/tag/v5.1.0)

依赖已更新

🌐 Dependencies updated

我们还投入时间准备了 Express 依赖的几个包的多个版本。这些大部分包被其他库和框架作为独立库使用。

🌐 We also invested time to prepare several releases in the packages that Express depend on. Most of this packages are used by other libraries and framework as individual libraries.

  • body-parser@2.2.0
    • 移除对 Brotli 和 AsyncLocalStorage 的旧版 Node.js 支持检查
    • 移除 unpipedestroy
  • router@2.2.0
    • 恢复 debug。现在使用 router 范围,而不是 express
    • 移除对 setImmediate 的旧版 node.js 支持检查
    • 弃用非原生的 Promise 支持
    • 移除 aftersafe-bufferarray-flattensetprototypeofmethodsutils-merge
  • finalhandler@2.1.0
    • 移除对 headersSentsetImmediate 和 http2 支持的旧版 Node.js 检查
    • 移除 unpipe
  • serve-static@2.2.0

谢谢,以及接下来做什么

🌐 Thanks and What’s Next

非常感谢过去一年中参与 Express 的每一位人员,所有贡献者所付出的努力都令人难以置信,没有他们我们无法做到。如果你自己无法成为贡献者,请考虑邀请你的公司在 OpenCollective 上为该项目提供资金支持。

🌐 Thanks so much to everyone involved in Express over the past year, the work all our contributors have put in is incredible, and we couldn’t do it without them. If you are not able to become a contributor yourself, please consider asking your companies to support the project financially on OpenCollective.

展望未来,我们很高兴继续保持动力。如果你还没有阅读,我们的Rewind 2024 + 2025 远景博客文章详细说明了我们的过去和未来方向。这包括已规划的性能封装、更好的自动化、安全加固等内容。

🌐 As we look ahead, we’re excited to keep building momentum. If you haven’t read it yet, our Rewind 2024 + 2025 Vision blog post lays out where we’ve been and where we’re headed. This includes performances scoped packages, better automation, security hardening, and more.

一项主要举措是我们新的性能工作组,专注于识别和解决 Express 中长期存在的瓶颈。我们很感激能在主权科技基金(STF)的支持下启动这一工作,他们正在帮助我们投资于核心基础设施的长期可持续性和性能。此外,我们还将致力于改进我们的 Typescript 开发体验,并采取下一步措施改进网站

🌐 One major initiative is our new Performance Working Group, focused on identifying and fixing long-standing bottlenecks in Express. We’re grateful to be kicking this off with support from the Sovereign Tech Fund (STF), who are helping us invest in long-term sustainability and performance of core infrastructure. Additionally, we will be working to improve our Typescript DX and taking next steps to improve the website.

是的,关于v6的讨论已经开始升温了。请关注更新,一如既往,在问题区见!

🌐 And yes, v6 discussions are already starting to heat up. Keep an eye out for updates, and as always, see you in the issues!

Big thanks to @wesleytodd, @blakeembrey, @bjohansebas, @UlisesGascon, @Phillip9587, @carpasse, @jonchurch, @ctcpip, @inigomarquinez, @carlosstenzel, @crandmck, @chrisdel101, @dpopp07, @Ayoub-Mabrouk, @jonkoops, @IamLizu, @marco-ippolito, @ipreencekmr, @ShubhamOulkar, @raksbisht, @jeffreybaird, @dougwilson, @mertcanaltin, @GeorgeShvab, @RobinTail, @EvanHahn, @rhodgkins, @cengizcmataraci, @Shantanugupta43, @italojs, @ljharb, @MaoShizhong, @aroyan, @Binilkks, @danielgindi, @papandreou, @jsoref, @bigbigDreamer, @broofa, @CommanderRoot, @andvea, @juanarbol, @agungjati, @alexandercerutti, @pr4j3sh, @hamirmahal, @slagiewka, @Abdel-Monaam-Aouini, @sazk07, @bhavya3024, @joshbuker, @almic, @FDrag0n, @Dmitry-Kondar, @attrid, @kristof-low, @gireeshpunathil, @UzairJ99, @choi2021, @hayden36, @joharkhan99, @peterh-capella, @johnburnett, @nicolasgandrade, @axhuwastaken, @abhijeetpandit7, @peterdanwan, @rehmansheikh222, @corydalis10, @mgsantos177, @wilyJ80, @LuiGeeDev, @juliogarciape, @aelmardhi, @Ahmed1monm, @erensarac, @tomasz13nocon, @tianbuyung, @GreyTearsDev, @aastha-cse, @krzysdz, @Miguelrom, @bnoordhuis, @MehfoozurRehman, @EasonLin0716, @grjan7, @mishrasur7, @gregfenton, @zareefhasan, @Tejas150, @jpricardo, @nikeee, @dotnetCarpenter, @engpetermwangi, @msimerson, @fetsorn, @manoharreddyporeddy, @lancatlin, @mifi, @meowingwhitey, @sheplu, @krsriq, @ravibisht, @wojtekmaj, @aqeelat, @melikhov-dev, @alexstrat, @isnifer, @TorstenDittmann, @Uzlopak, @gurgunday, @kurtextrem, @hdtmccallie, @proudparrot2, @bewinsnw, @jonboulle, @alexander-akait, @alxndrsn, @DimitriPapadopoulos, @greggman, @jkbach, @julien-c, @risu729, @JohnSimumatik, @dhouck, @pedro-php, @aminerol, @robertsky, @ipetrouchtchak-fi, @tinhochu, @Lord-Kamina, @joshkel, @raiandexter0607, @NateEag, @rmhaiderali, @ljeda

有兴趣写一篇文章吗?查看我们的指南以开始吧。

阅读指南