我们很高兴地宣布 Node.js 21 正式发布!该版本的亮点包括将 V8 JavaScript 引擎更新到 11.8、稳定的 fetch 和 WebStreams、一个新的实验性标志(用于将模糊代码的解释从 CommonJS 更改为 ES 模块)(–experimental-default-type)、测试运行器的多项更新等!
本月晚些时候,当 Node.js 20 进入长期支持(LTS)阶段时,Node.js 21 将取代 Node.js 20,成为我们的 “当前 “版本系列。根据发布计划,Node.js 21 将在未来 6 个月内作为 “当前 “版本发布,直至 2024 年 4 月。
其他值得注意的变更
[740ca5423a] – doc:将 fetch/webstreams 从实验版升级到稳定版 (Steven) #45684
[85301803e1] – esm:–experimental-default-type 标志用于翻转模块默认值 (Geoffrey Booth) #49869
[705e623ac4] – esm:移除 globalPreload 钩子(被 initialize 取代) (Jacob Smith) #49144
[e01c1d700d] -fs:为 writeFile() 函数添加 flush 选项 (Colin Ihrig) #50009
[1948dce707] – (SEMVER-MAJOR) fs:添加 globSync 实现 (Moshe Atlow) #47653
(SEMVER-MINOR) lib:添加 WebSocket 客户端(Matthew Aitken) #49830
[95b8f5dcab] – stream:优化 Writable(Robert Nagy) #50012
[7cd4e70948] – (SEMVER-MAJOR) test_runner:支持传递 globs (Moshe Atlow) #47653
[1d220b55ac] – vm:未设置 importModuleDynamically 时使用默认 HDO (Joyee Cheung) #49950
Semver-Major 提交
[ac2a68c76b] – (SEMVER-MAJOR)构建:放弃对 Visual Studio 2019 的支持(Michaël Zasso) #49051
[4e3983031a] – (SEMVER-MAJOR) 联编:提升支持的 macOS 和 Xcode 版本 (Michaël Zasso) #49164
[5a0777776d] – (SEMVER-MAJOR) crypto:不要覆盖 _writableState.defaultEncoding (Tobias Nießen) #49140
[162a0652ab] – (SEMVER-MAJOR) deps:将 ICU 最低版本提升至 73 (Michaël Zasso) #49639
[17a74ddd3d] – (SEMVER-MAJOR) 软件包:更新 V8 至 11.8.172.13 (Michaël Zasso) #49639
[e9ff81016d] – (SEMVER-MAJOR) 文件:将 llhttp 更新至 9.1.2 (Paolo Insogna) #48981
[7ace5aba75] – (SEMVER-MAJOR) 事件:验证on和once选项(Deokjin Kim) #46018
[b3ec13d449] -(SEMVER-MAJOR)fs:调整读取方法中的位置验证(Livia Medeiros) #42835
[1948dce707] – (SEMVER-MAJOR) fs:添加 globSync 实现(Moshe Atlow) #47653
[d68d0eacaa] – (SEMVER-MAJOR) http:在分块响应时减少分块响应的部分内容(Robert Nagy) #50167
[c5b0b894ed] – (SEMVER-MAJOR) lib:将 URL/URLSearchParams 标记为不可克隆和不可转移(Chengzhong Wu) #47497
[3205b1936a] – (SEMVER-MAJOR) lib:移除软件包阅读器的 aix 目录情况(Yagiz Nizipli) #48605
[b40f0c3074] – (SEMVER-MAJOR) lib:添加 navigator.hardwareConcurrency (Yagiz Nizipli) #47769
[4b08c4c047] – (SEMVER-MAJOR) lib: runtime deprecate punycode (Yagiz Nizipli) #47202
[3ce51ae9c0] – (SEMVER-MAJOR) 模块:统一 ESM 和 CJS 之间的错误代码 (Antoine du Hamel) #48606
[7202859402] – (SEMVER-MAJOR) net:不将 server.maxConnections=0 视为无限(无知) #48276
[c15bafdaf4] – (SEMVER-MAJOR)网络:连接时只延迟_final调用(Jason Zhang) #47385
[6ffacbf0f9] – (SEMVER-MAJOR) node-api:重命名内部 NAPI_VERSION 定义(Chengzhong Wu) #48501
[11af089b14] – (SEMVER-MAJOR) src:更新 NODE_MODULE_VERSION 为 120 (Michaël Zasso) #49639
[d920b7c94b] – (SEMVER-MAJOR) src:克隆不可序列化对象时抛出 DOMException (Chengzhong Wu) #47839
[64549731b6] – (SEMVER-MAJOR) src:传输不可传输对象时抛出 DataCloneError(Chengzhong Wu) #47604
[dac8de689b] – (SEMVER-MAJOR) 流:为策略使用私有属性(Yagiz Nizipli) #47218
[1fa084ecdf] – (SEMVER-MAJOR)流:为编码使用私有属性(Yagiz Nizipli) #47218
[4e93247079] – (SEMVER-MAJOR) stream:使用私有属性进行压缩(Yagiz Nizipli) #47218
[527589b755] – (SEMVER-MAJOR) test_runner:禁止在运行选项中使用数组 (Raz Luvaton) #49935
[7cd4e70948] – (SEMVER-MAJOR) test_runner:支持传递 globs (Moshe Atlow) #47653
[2ef170254b] – (SEMVER-MAJOR) tls:对 options.minDHSize 使用 validateNumber (Deokjin Kim) #49973
[092fb9f541] – (SEMVER-MAJOR) tls:为 options.checkServerIdentity 使用 validateFunction (Deokjin Kim) #49896
[ccca547e28] – (SEMVER-MAJOR) util:运行时废弃返回 Promise 的函数(Antoine du Hamel) #49609
[4038cf0513] – (超级嗅探狗-MAJOR) vm:冻结依赖解释数组(Antoine du Hamel) #49720
Semver-Minor 提交
[3227d7327c] – (SEMVER-MINOR) deps:更新 uvwasi 至 0.0.19 (Node.js GitHub Bot) #49908
[e28dbe1c2b] – (SEMVER-MINOR) lib:添加 WebSocket 客户端(Matthew Aitken) #49830
[9f9c58212e] – (SEMVER-MINOR) test_runner、cli:添加 –test-concurrency 标志(Colin Ihrig) #49996
[d37b0d267f] – (SEMVER-MINOR) wasi:最新 uvwasi 版本需要更新(Michael Dawson) #49908
Semver-Patch 提交
[33c87ec096] – 基准:修复 fs 长凳上的竞赛条件(Vinicius Lourenço) #50035
[3c0ec61c4b] – 基准:为 accessSync 长凳添加热身(Rafael Gonzaga) #50073
[1a839f388e] – 基准:改进 blob、文件基准的配置 (Vinícius Lourenço) #49730
[86fe5a80f3] – 基准:为 blob 添加新基准(Vinícius Lourenço) #49730
[6322d4f587] – 联编:修复 IBM i 联编与 Python 3.9 (Richard Lau) #48056
[17c55d176b] – 联编:重置 embedder 字符串为”-node.0″ (Michaël Zasso) #49639
[f10928f926] – 加密:使用 X509_ALGOR 访问器,而不是进入 X509_ALGOR (David Benjamin) #50057
[136a96722a] – 加密:说明禁用的 SharedArrayBuffer (Shelley Vohr) #50034
[17b9925393] – 密码:加载无效 PFX 数据时返回清除错误 (Tim Perry) #49566
[ca25d564c6] – 部署:将 npm 升级到 10.2.0 (npm 团队) #50027
[f23a9353ae] – 文件:将 corepack 升级至 0.21.0 (Node.js GitHub Bot) #50088
[ceedb3a509] – 文件:将 simdutf 更新至 3.2.18 (Node.js GitHub Bot) #50091
[0522ac086c] – 文件:将 zlib 更新至 1.2.13.1-motley-fef5869 (Node.js GitHub Bot) #50085
[4f8c5829da] – 文件:将 googletest 更新至 2dd1c13 (Node.js GitHub Bot) #50081
[588784ea30] – 版本:更新 undici 至 5.25.4(Node.js GitHub 僵尸程序) #50025
[c9eef0c3c4] – 版本更新:将 googletest 更新至 e47544a (Node.js GitHub Bot) #49982
[23cb478398] – 部署:将 ada 更新至 2.6.10 (Node.js GitHub Bot) #49984
[61411bb323] – 文件:修复对未声明函数 “ntohl “和 “htons “的调用 (MatteoBax) #49979
[49cf182e30] – 文件:将 ada 更新至 2.6.9 (Node.js GitHub Bot) #49340
[ceb6df0f22] – 文件:将 ada 更新至 2.6.8 (Node.js GitHub Bot) #49340
[b73e18b5dc] – 文件:将 ada 升级至 2.6.7 (Node.js GitHub Bot) #49340
[baf2256617] – 数据集:将 ada 更新至 2.6.5 (Node.js GitHub Bot) #49340
[a20a328a9b] – 文件:将 ada 更新至 2.6.3 (Node.js GitHub Bot) #49340
[3838b579e4] – 资源:V8: cherry-pick 8ec2651fbdd8 (Abdirahim Musse) #49862
[668437ccad] – deps:V8: cherry-pick b60a03df4ceb (Joyee Cheung) #49491
[f970087147] – deps:V8: backport 93b1a74cbc9b (Joyee Cheung) #49419
[4531c154e5] – 文件:V8: cherry-pick 8ec2651fbdd8 (Michaël Zasso) #49639
[9ad0e2cacc] – deps:V8: cherry-pick 89b3702c92b0 (Michaël Zasso) #49639
[dfc9c86868] – deps:V8: cherry-pick de9a5de2274f (Michaël Zasso) #49639
[186b36efba] – deps:V8: cherry-pick b5b5d6c31bb0 (Michaël Zasso) #49639
[867586ce95] – deps:V8: cherry-pick 93b1a74cbc9b (Michaël Zasso) #49639
[4ad3479ba7] – deps:V8: cherry-pick 1a3ecc2483b2 (Michaël Zasso) #49639
[660f902f16] – 文件:V8 补丁以避免重复的 zlib 符号 (Michaël Zasso) #49639
[f7c1d410ad] – 文件:删除 V8 中 C++20 特性的使用 (Michaël Zasso) #49639
[9c4030bfb9] – 文件:避免 ASan 编译错误 (Michaël Zasso) #49639
[5f05cc15e6] – 文件:禁用 V8 并发火花塞编译(Michaël Zasso) #49639
[42cd952dbd] – 版本说明:禁用无关的 V8 警告(Michaël Zasso) #49639
[88cf90f9c4] – 文件:始终将 V8_EXPORT_PRIVATE 定义为 no-op (Michaël Zasso) #49639
[8609915951] – doc:改进 ccache 解释 (Chengzhong Wu) #50133
[91d21324a9] – doc: move danielleadams to TSC non-voting member (Danielle Adams) #50142
[34fa7043a2] – doc:修正 fs.readdir 递归选项的描述 (RamdohokarAngha) #48902
[81e4d2ec2f] – doc:提及在环境设置之前读取的文件(Rafael Gonzaga) #50072
[0ce37ed8e9] – doc:将权限模型移至主动开发(Rafael Gonzaga) #50068
[3c430212c3] – doc:添加获取补丁主次的命令(Rafael Gonzaga) #50067
[e43bf4c31d] – doc:在 fs 中使用精确的 promise 术语 (Benjamin Gruenbaum) #50029
[d3a5f1fb5f] – doc:在测试运行器中使用准确的术语(Benjamin Gruenbaum) #50028
[24dea2348d] – doc:澄清如何运行示例的说明文字 (Anshul Sinha) #39020
[f3ed57bd8b] – doc:为电子 28 预留 119 (David Sanders) #50020
[85c09f178c] – doc:更新合作者代词(Tierney Cyren) #50005
[099e2f7bce] – 文档:更新摘要模块记录规范链接(Rich Trott) #49961
[47b2883673] – doc:更新窗口的构建文档(Claudio W) #49767
[7b624c30b2] – doc:更新关于虚拟机修复的 CHANGELOG_V20 (Joyee Cheung) #49951
[1dc0667aa6] – doc:记录危险的符号链接行为 (Tobias Nießen) #49154
[bc056c2426] – doc:在 API docs 中添加主要 ARIA 地标 (Rich Trott) #49882
[740ca5423a] – doc:将 fetch/webstreams 从 experimental 升级到 stable (Steven) #45684
[f802aa0645] – doc:修正 “partial “错字(Colin Ihrig) #48657
[6fda81d4f5] – doc:提及 Navigator 是部分实现(Moshe Atlow) #48656
[6aa2aeedcb] – 文档:将 Node.js 19 标注为生命周期结束 (Richard Lau) #48283
[0ee9c83ffc] – 错误:提高 determine-specific-type 的性能 (Aras Abbasi) #49696
[4f84a3d200] – errors:改进 errors.js 中的 formatList (Aras Abbasi) #49642
[cc725a653a] – 错误:提高实例化的性能 (Aras Abbasi) #49654
[d1ef6aa2db] – esm:使用导入属性而非导入断言 (Antoine du Hamel) #50140
[19b470f866] – esm:在–default-type下绕过CommonJS加载器 (Geoffrey Booth) #49986
[9c683204db] – esm:在模块作用域中取消标记无扩展的 javascript 和 wasm (Geoffrey Booth) #49974
[05be31d5de] – ESM:提高 getFormatOfExtensionlessFile 的速度 (Yagiz Nizipli) #49965
[aadfea4979] – esm:改进内部函数的 JSDoc 注释 (Antoine du Hamel) #49959
[7f0e36af52] – esm:使用 file.URL 修复 JSON 文件的缓存碰撞 (Antoine du Hamel)URL (Antoine du Hamel) #49887
[85301803e1] – esm:用于翻转模块默认值的 –experimental-default-type 标志 (Geoffrey Booth) #49869
[f42a103991] – esm:模块代码需要大括号 (Geoffrey Booth) #49657
[705e623ac4] – ESM:移除 globalPreload 钩子(被 initialize 取代)(Jacob Smith) #49144
[18a818744f] -fs:改善 readdirSync 的错误性能 (Yagiz Nizipli) #50131
[d3985296a9] -fs:修复 unlinkSync 类型 (Yagiz Nizipli) #49859
[6bc7fa7906] -fs:改进同步 chmod+fchmod 的错误 perf (CanadaHonk) #49859
[6bd77db41f] -fs:提高同步 *times 的错误性能 (CanadaHonk) #49864
[bf0f0789da] -fs:提高写入同步(writevSync)的错误性能 (IlyasShabi) #50038
[8a49735bae] -fs:为 createWriteStream() 添加 flush 选项 (Colin Ihrig) #50093
[ed49722a8a] -fs:提高 ftruncateSync 的出错性能(André Alves) #50032
[e01c1d700d] -fs:为 writeFile() 函数添加 flush 选项 (Colin Ihrig) #50009
[f7a160d5b4] -fs:提高 fdatasyncSync 的出错性能 (Jungku Lee) #49898
[813713f211] -fs:从同步分支而非单独实现中抛出错误 (Joyee Cheung) #49913
[b866e38192] – http:重构使服务器名选项规范化可测试(Rongjian Zhang) #38733
[2990390359] – 检查器:简化 dispatchProtocolMessage (Daniel Lemire) #49780
[d4c5fe488e] – 函数库:修复 compileFunction 在负数时抛出范围错误 (Jithil P Ponnan) #49855
[589ac5004c] – 数据库:更快的内部 createBlob (Vinícius Lourenço) #49730
[952cf0d17a] – 库:减少 validateObject 的开销 (Vinicius Lourenço) #49928
[fa250fdec1] – 数据库:使获取同步并返回 Promise (Matthew Aitken) #49936
[1b96975f27] – 数据库:修复 primordials 类型 (Sam Verschueren) #49895
[6aa7101960] – 库:更新 HTTPRequestOptions 的 jsdoc 中的参数(Jungku Lee) #49872
[a4fdb1abe0] – lib,test: 不要对 Buffer.kMaxLength 进行硬编码 (Michaël Zasso) #49876
[fd21429ef5] – lib:更新始终开启 Atomics API 的用法 (Michaël Zasso) #49639
[bac85be22d] – 元:ping TSC 用于离线 (Tobias Nießen) #50147
[609b13e6c2] – 元:将 actions/upload-artifact 从 3.1.2 升级到 3.1.3 (dependabot[bot]) #50000
[3825464ef4] – 元:将 actions/cache 从 3.3.1 升级到 3.3.2 (dependabot[bot]) #50003
[49f0f9ca11] – 元:将 github/codeql-action 从 2.21.5 升级到 2.21.9 (dependabot[bot]) #50002
[f156427244] – 元:将 actions/checkout 从 3.6.0 升级到 4.1.0 (dependabot[bot]) #50001
[0fe673c7e6] – 元:使用新名称更新网站团队(Rich Trott) #49883
[51f4ff2450] – 模块:将助手移出 cjs 加载器 (Geoffrey Booth) #49912
[7517c9f95b] – 模块,esm:模块文件的 jsdoc (Geoffrey Booth) #49523
[b55adfb4f1] – node-api:更新头文件以更好地支持 wasm (Toyo Li) #49037
[b38e312486] – node-api:直接从 GC 运行终结器 (Vladimir Morozov) #42651
[0f0dd1a493] – os:缓存 homedir,移除 getCheckedFunction (Aras Abbasi) #50037
[0e507d30ac] – perf_hooks:减少新用户定时的开销 (Vinicius Lourenço) #49914
[328bdac7f0] – perf_hooks:减少性能观察者条目列表的开销(Vinicius Lourenço) #50008
[e6e320ecc7] – perf_hooks:减少新资源时序的开销(Vinicius Lourenço) #49837
[971af4b211] – quic:修复 quic/session.cc 中的覆盖性警告 (Michael Dawson) #49865
[546797f2b1] – quic:防止复制 ngtcp2_cid (Tobias Nießen) #48561
[ac6f594c97] – quic:处理新的 coverity 警告 (Michael Dawson) #48384
更多 Node v21.0.0 (Current) | Node.js (nodejs.org)
Windows 32-bit Installer: https://nodejs.org/dist/v21.0.0/node-v21.0.0-x86.msi
Windows 64-bit Installer: https://nodejs.org/dist/v21.0.0/node-v21.0.0-x64.msi
Windows ARM 64-bit Installer: https://nodejs.org/dist/v21.0.0/node-v21.0.0-arm64.msi
Windows 32-bit Binary: https://nodejs.org/dist/v21.0.0/win-x86/node.exe
Windows 64-bit Binary: https://nodejs.org/dist/v21.0.0/win-x64/node.exe
Windows ARM 64-bit Binary: https://nodejs.org/dist/v21.0.0/win-arm64/node.exe
macOS 64-bit Installer: https://nodejs.org/dist/v21.0.0/node-v21.0.0.pkg
macOS Apple Silicon 64-bit Binary: https://nodejs.org/dist/v21.0.0/node-v21.0.0-darwin-arm64.tar.gz
macOS Intel 64-bit Binary: https://nodejs.org/dist/v21.0.0/node-v21.0.0-darwin-x64.tar.gz
Linux 64-bit Binary: https://nodejs.org/dist/v21.0.0/node-v21.0.0-linux-x64.tar.xz
Linux PPC LE 64-bit Binary: https://nodejs.org/dist/v21.0.0/node-v21.0.0-linux-ppc64le.tar.xz
Linux s390x 64-bit Binary: https://nodejs.org/dist/v21.0.0/node-v21.0.0-linux-s390x.tar.xz
AIX 64-bit Binary: https://nodejs.org/dist/v21.0.0/node-v21.0.0-aix-ppc64.tar.gz
ARMv7 32-bit Binary: https://nodejs.org/dist/v21.0.0/node-v21.0.0-linux-armv7l.tar.xz
ARMv8 64-bit Binary: https://nodejs.org/dist/v21.0.0/node-v21.0.0-linux-arm64.tar.xz
Source Code: https://nodejs.org/dist/v21.0.0/node-v21.0.0.tar.gz
Other release files: https://nodejs.org/dist/v21.0.0/
Documentation: https://nodejs.org/docs/v21.0.0/api/