迁移到 Express 5

概述

Express 5.0 仍处于 beta 发布阶段,但这里是发布中将要进行的更改以及如何将 Express 4 应用程序迁移到 Express 5 的预览。

要安装最新的测试版并预览 Express 5,请在应用程序根目录中输入以下命令:

$ npm install "express@>=5.0.0-beta.1" --save

然后,您可以运行自动化测试以查看失败的原因,并根据下面列出的更新修复问题。解决测试失败后,运行您的应用程序以查看发生了什么错误。您会立即发现应用程序是否使用了不受支持的任何方法或属性。

Express 5 的变化

删除的方法和属性

  • PulK632CMUIy0XADqPTo/fkcXOE2rKZcPxeEtEC8LBJktC2zp66XAxtRcMYnbFnPp9PtCFb9MwxdNfoanBtjJg==

  • haEykEiMQvhhrMh4x6eq4TBjld/2yyVq0PYH/FFZpOIgI6FtpUAgBD5XsHulT1DbzcXz7WC+ZvBHPgWWAG4YTQ==

  • 1WpNAh5rKNOFwFtRJ4pWitU93Kuz8ojQc+6wJRNQqMEX4H5OqVtFEEXNavnndS/D0rlJjRKufVBw/dUKpVP1U+smArcJCU0UjFZw7yF6hOQ=

  • rzDCZzlCNAHCC6MHWY/QBo8PC+2p9Ri8VUdrRKzZMF9xB873yOap1/wmcf9d5YeoODI1HrVgD0XtOMkf3um+1nXgbbKKJGAsOPwe335VDY7iIpq5KGFKit8SC0/xtRiyTEIkSd6E1oNbMI4r4NitKw==

  • hEhIm5X/baeM9Rgsg45wOk2E+D/Kw6eYoeWCT2Ft3iYvIYPWjc8fgYVdoMRy6J/0ktBhmsWY1l4I0tEYWq6AqK3F0bDbgONvwBupbh3gHXw=

  • WuEiglHyQ9SwwBvGhWxUv0dDiSduGDja8fzLp6TCb4HlUD8j74jRK0RLVIwN/lgvtMrGYjUtkS3PUvI/jVPwdLVBSUKVrpvrQxE8iYPa1bU=

  • fphYCbIJ145GzIOOQ1belssM/Ndxite2ZRerRAcgM6hEza+u14EZwFI8FUJkdEc/KwEV3dCLVP2+SV1ZBF2dTlUntl821iQdVPtcARrKHRs=

  • yk/Ka3S7tbBM071fTE9KRtDEyNjucFv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3D0fSwZizam+TOyyNSOh3STIAQ/bmq3eQ+5aC0BH/8TJR2IrnU1/zMvf7iCDHEDYh1TEtWU2v1ECeyzMurkGvsU2k28PpCok0H2fxrJSnzJpLC3J9RZBOMg1/XAtr6izpnkmvGSo05CerpkNtll24YLG8YDb7pujE70QmPuvn0uPbHtRr8arI9eup6m1WEuehKYbLWlR+3o885Em50FHJ/ma7vURZeMwZ2Tbx4gjkY5xOBAF6zw2+K7B+HARPjrmxGz0/HnhDrqImRV+6SnolKW0JJ/3+srKa+p5I/mRpozJX8ZY0xYPmPjpMPy/eMKHcPBdaaNkbMwch93syGl1XDhGbZJibDsXDgoM0r50GbsCmSc5OstVbKREOx8pqkvhgKlPIFZ4wqkDM7dhBdpIQ

从中间件和处理程序处理的拒绝 promise

BoRG8dD9OQiJZBo3zstMHoq7XTjDatwOYW5evToRYi3TYf7GyWy2qZc4lz4fKWGgXTFhRUCzQoLdLJBh0raomHfv9eu1JCBZwynDwZQQufekK8mnjYnrRmDp/CD00W4nQZLpXjBzDKDBjqj5p9ldqJV24cnDYiQeRYtyoTZpSN1yDIjjwYiymhAfWLHN+UqUjd6lHA35L32N5v1bxgDW5Za8DLwDusZE42I88OiTq30xJoYk9icGSzOfWXPIT+09J2Z32Ra3MD7Hof85gSCzcszq72r/8FTnyTqNiBh0PwbzSppLorPvVKuV7WKkf1xE9V4SohCN1sA7OdQboWdNk4niZQpNrqi9hQb43F1xMxuJLvtv6xdBknaMGwgZV59x2e2wZx3WTrdJ2eROLppiWENPzIfXsCnLloYMPWj921knhgFIxurNTYwEsPWRVj/kQkZFHmInJo0Wce6F/Akxwx5E1aRu6D/yqlJfS7g6kqfWLW/v2Ybv4NnL0uV5AuK3CAws28rnEeDGsmKxsYnaMfMAaTiQApPjYE0hzSDUC3kbVesivzZQaYI7v2erAHN97G4H2bZ9NJKw5npUl75jZ1YZXc5zuGe7XUsT/MtYwqvJ8iDpLoiN+1aSukvQjVnp

NnjUYCnrHDcLj87qAyEc77Isu/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XHiOyYwqCNxKWUP6IhECevniV+w==