Node.js 16 发行注记


Red Hat build of Node.js 16

用于 Node.js 16 LTS

Red Hat Customer Content Services

摘要

本发行注记包含与 Node.js 16 LTS 相关的重要信息。

前言

发布日期:2021 年 12 月 21 日

第 1 章 所需的基础架构组件版本

使用 Red Hat build of Node.js 时,需要以下基础架构组件。除了明确指定为支持的组件外,红帽不提供对这些组件的支持。

Expand
组件名称版本

Nodeshift

2.1.1

npm 8

8.1.2

OpenShift Container Platform (OCP)[a]

3.11, 4.5

git

2.0 或更高版本

oc 命令行工具

3.11 或更高版本[b]

[a] 红帽支持 OCP
[b] oc CLI 工具的版本应与您正在使用的 OCP 版本对应。

第 2 章 功能

本节介绍红帽构建的 Node.js 16 发行版本中引入的功能更改。

2.1. 新的和更改的功能

Node.js 16 LTS 具有以下红帽构建的 Node.js 支持的新功能和增强:

有关 Node.js 16 LTS 的详细信息,请参阅上游发行注记上游文档

Red Hat build of Node.js 在启用了 FIPS 的 RHEL 系统上运行,并使用 RHEL 提供的 FIPS 认证库。

2.1.2. V8 JavaScript 引擎从 v8.4 升级到 v9.4

V8 JavaScript 引擎已升级到 v9.4。

引擎包含新功能,如 ECMAScript RegExp Match Indices,它在正则表达式中提供捕获的字符串的开始和结束索引。当正则表达式包含 /d 标志时,可以通过匹配对象上的 .indices 属性访问索引数组。例如:

> const matchObj = /(Java)(Script)/d.exec('JavaScript');
undefined
> matchObj.indices
[ [ 0, 10 ], [ 0, 4 ], [ 4, 10 ], groups: undefined ]
> matchObj.indices[0]; // Match
[ 0, 10 ]
> matchObj.indices[1]; // First capture group
[ 0, 4 ]
> matchObj.indices[2]; // Second capture group
[ 4, 10 ]

升级的 V8 JavaScript 引擎还提供以下 JavaScript 语言功能:

  • Array.prototype.at
  • 原因出错
  • Object.hasOwn

有关 V8 JavaScript Engine 中可用的更改的更多信息,请参阅 V8 博客

2.1.3. timers Promises API

Timers Promises API 是 Node.js 16 LTS 中一个新的稳定功能。

Timers Promises API 提供了一组替代的计时器函数,用于返回 Promise 对象。此 API 不再需要使用 util.promisify ()。例如:

import { setTimeout } from 'timers/promises';
async function run() {
  await setTimeout(5000);
  console.log('Hello, World!');
}
run();

2.1.4. 为 OpenShift 更新了 Node.js metering 标签

您可以在 Node.js pod 中添加 metering 标签,并通过 OpenShift Metering Operator 检查红帽订阅详情。

注意

不要将 metering 标签添加到 Operator 部署和管理的任何 pod。

自 Node.js 14 LTS 发行版本中介绍后,OpenShift 的 Node.js metering 标签已被修改。

Node.js 16 LTS 使用以下更新的 metering 标签:

  • com.company: Red_Hat
  • rht.prod_name: "Red_Hat_Runtimes"
  • rht.prod_ver: 2021-Q4
  • rht.comp: Node.js
  • rht.comp_ver: 16.x.x
  • rht.subcomp:
  • rht.subcomp_t: application

如需更多信息,请参阅 Metering 文档。

如需有关标签的更多信息,请参阅 了解如何更新节点上的标签

注意
  • 不要将 metering 标签添加到 Operator 或模板部署和管理的任何 pod。
  • rht.comp_ver 中的 x.x 替换为您在部署中使用的 Node.js 的产品版本。例如,如果 Node.js 产品版本是 16.13.1,请在标签中指定 16.13.1。
  • 确保为 Node.js 分配一个空白值。

2.1.5. Red Hat Enterprise Linux 9 支持

此 Red Hat build of Node.js 发行版本也经过认证,可用于 Red Hat Enterprise Linux 9。

红帽现在为 Red Hat build of Node.js 16 LTS 版本提供一系列容器镜像,它们已在 Red Hat Enterprise Linux 9 中使用。您可以使用这些容器镜像在 Red Hat Enterprise Linux 9 主机上构建并运行 Node.js 应用程序。有关认证容器镜像的更多信息,请参阅 发布组件

2.2. 已弃用的功能

红帽构建的 Node.js 16 中已弃用以下功能。

注意

有关本发行版本中已弃用或删除功能的更多信息,请参阅 nodejs.org 网站

对于多个核心模块,这个版本包括对 process.binding () 函数的访问的运行时弃用。例如: process.binding ('http_parser')

2.2.2. OpenShift 的旧 Node.js metering 标签

OpenShift 的 Node.js metering 标签(最初在 Node.js 14 LTS 版本中引入)现在被一组较新的 metering 标签替代。

本发行版本中弃用了以下 Node.js metering 标签:

  • com.redhat.component-name: Node.js
  • com.redhat.component-type: application
  • com.redhat.component-version: 16.x.x
  • com.redhat.product-name: "Red_Hat_Runtimes"
  • com.redhat.product-version: 2021-Q4

2.3. 技术预览功能

在 Node.js 16 LTS 版本中,以下功能可作为技术预览功能提供。

2.3.1. Web Crypto API

Web Crypto API 是标准 W3C Web Cryptography API 的实现。Web Crypto API 可通过使用 require ('crypto').webcrypto 语句来访问。例如:

const { subtle } = require('crypto').webcrypto;

(async function() {

  const key = await subtle.generateKey({
    name: 'HMAC',
    hash: 'SHA-256',
    length: 256
  }, true, ['sign', 'verify']);

  const digest = await subtle.sign({
    name: 'HMAC'
  }, key, 'I love cupcakes');

})();

2.3.2. Web Streams API

Web Streams API 是 WHATWG 流标准用于处理流数据的实现。由于是实验性的,因此此发行版本中的全局对象不会公开 Web Streams API。Web Streams API 只能通过新的 stream/web 核心模块访问。例如:

import { ReadableStream, WritableStream } from 'stream/web';
// Or from 'node:stream/web'

2.3.3. ESM Loader Hooks API

ESM Loader Hooks API 整合 ECMAScript 模块(ESM)加载程序 hook,以表示未来加载程序链所需的步骤:

  1. 解决方案 :解析 [+ getFormat]
  2. load: getFormat + getSource + convertSource

为实现一致性,getGlobalPreloadCode loader hook 已重命名为 globalPreload

导出一个或多个过时的 hook 的任何加载程序都会触发单个弃用警告,该警告列出了错误 hook。

2.3.4. 在 worker 线程间共享原始数据的新类

Blob 类封装了可在多个 worker 线程间安全共享的不可变原始数据。

blob缓冲区 类的子类。

2.3.5. test Runner 模块

node:test 模块有助于创建以 Test anything Protocol (TAP)格式报告结果的 JavaScript 测试。

要导入测试运行程序模块,请使用以下语法:

import test from 'node:test';
注意

导入测试运行程序模块时,您必须指定 node: 前缀,如上例所示。node: 前缀表示载入核心模块。如果省略了 node: 前缀,Node.js 会尝试从 Node.js 模块的"userland"生态系统导入测试模块,而不是从 Node.js 内核导入 test runner 模块。

以下代码显示了一个带有两个子tests 的父测试的示例实现:

test('top level test', async (t) => {
  await t.test('subtest 1', (t) => {
    assert.strictEqual(1, 1);
  });

  await t.test('subtest 2', (t) => {
    assert.strictEqual(2, 2);
  });
});

如需更多信息,请参阅 Node.js Test Runner 文档

2.4. 支持的构架

Node.js 构建器镜像和 RPM 软件包可用于以下 CPU 架构:

  • AMD x86_64
  • ARM64
  • OpenShift 环境中的 IBM Z (s390x)
  • OpenShift 环境中的 IBM Power 系统(ppc64le)

第 3 章 发行版本组件

第 4 章 修复的问题

此发行版本包含 Node.js 16 LTS 的社区版本中所有修复的问题。

第 5 章 已知问题

没有已知的影响此版本的问题。

没有已知的、会影响到此版本所需基础架构组件的问题。

法律通告

Copyright © 2023 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部