The Node.js team has released version 21, which also means that Node 20 will shortly become the active Long Term Support (LTS) release. New features include stable fetch and WebStreams, a flag for defaulting .js files to ECMAScript modules (esm) rather than CommonJS, and an updated test runner.
There is also experimental support for a WebSocket client in Node.js, though not yet a server, however, both are already available via modules. “A webSocket server … may follow”, according to TSC member Benjamin Gruenbaum.
Node.js 21 also edges closer towards using ESM rather than CommonJS for its default module system. Currently files with a .cjs or .js extension are treated as CommonJS, but a new experimental flag changes this so that .js files are treated as ESM.
Node.js releases appear every six months, and even-numbered releases become LTS. Odd-numbered releases like 21 will never be LTS, but they do herald the promotion of the previous current release to active so are still significant. The purpose of the odd-numbered releases is to give developers “access to interesting new features early … a great way to test and see what’s coming,” according to Rafael Gonzaga, Node.js Technical Steering Committee member.
Developers may be equally interested in features introduced in Node.js 19 and 20 that are now becoming current. A key feature in Node.js 20 is a stable Test Runner built into the core, with building blocks for authoring and running tests, and a watch mode to check for file changes – though note that not all the features of the Test Runner are stable, with code coverage and reporting still being experimental.
Node.js 20 also has a focus on performance with “many improvements to the fundamental parts of the runtime” according to the release notes. There is also experimental support for single executable applications , which means applications can be distributed without requiring Node.js to be installed, though in the initial release it supports CommonJS modules only.