BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Node.js 21 Release Updates V8 Engine, WebStreams Module and Test Runner

Node.js 21 Release Updates V8 Engine, WebStreams Module and Test Runner

The Node.js team has recently released Node.js 21. This release introduces changes such as updates to the V8 JavaScript engine, stable fetch and WebStreams modules, an experimental flag for altering module defaults, a built-in WebSocket client, and enhancements to the test runner. Notably, as an odd-numbered release, Node.js 21 will not receive LTS (long-term support) status.

The fetch and WebStreams modules have been promoted to stable within Node.js 21. This promotion impacts modules like WebStreams, FormData, Headers, Request, Response, and fetch.

Additionally, the release includes an experimental WebSocket client that can be enabled with the --experimental-websocket flag, aligning with browser-compatible standards to simplify JavaScript development for applications that run on both frontend and backend.

Node.js 21 includes an update of the V8 engine, now at version 11.8, which brings improved performance and new language features. Notable features include Array grouping, ArrayBuffer.prototype.transfer, and WebAssembly extended-const expressions. This upgrade helps reduce dependencies on external libraries.

The test runner in Node.js has been enhanced to support glob expressions when specifying the --test parameter. This allows for more efficient and flexible test execution, making it easier to run tests across multiple directories using powerful glob patterns.

A new flag, --experimental-default-type, has been introduced. This flag allows developers to customize the default module system, enabling them to specify whether input files should be interpreted as ES modules or CommonJS.

The Node.js 21 release contains several performance-focused enhancements, including on URL, fetch, streams, node:fs, and HTTP. These refinements are intended to contribute to the overall runtime performance.

The integration of the global navigator object in Node.js 21 enhances web interoperability, allowing developers to access hardware concurrency information through navigator.hardwareConcurrency.

Rafael Gonzaga, a member of the Node.js Technical Steering Committee (TSC), encourages users to explore Node.js 21, stating:

"If you're interested in getting access to interesting new features early, Node.js 21 is a great way to test and see what's coming. Our release schedule specifically covers this. If you're already in active deployment or if you are planning for it, Node.js 20 and 18 LTS are for you." Node.js 21 becomes the current release, with this status lasting for six months until April 2024. Node.js 16 (LTS) has reached its end of life (EOL), prompting developers to plan upgrades to Node.js 18 (LTS) or Node.js 20 (LTS) for continued support and compatibility with the latest features.

The full list of changes is available in the Node.js 21 pull request within the associated GitHub project.

About the Author

Rate this Article

Adoption
Style

BT