Node.js 22 Brings require() Support for ES Modules, Enhanced WebSockets, and V8 Engine Update
Node.js 22 Released with Key Enhancements: ECMAScript Modules, WebSocket Upgrades, and V8 Update
Node.js 22, the latest version of the widely-used JavaScript runtime, has been officially released, bringing several new features, including enhanced support for ECMAScript modules, an improved WebSocket client, and a refreshed version of the Google V8 JavaScript engine. This release marks a significant step forward in performance, compatibility, and developer experience.
Unveiled on April 24, Node.js 22 can now be downloaded from the official Node.js website. One of the standout features is the addition of require() support for synchronous ECMAScript module graphs, which is available under the flag --experimental-require-module
. When enabled, and if the ES module meets specific criteria, developers can use require()
to load these modules directly. This update aligns Node.js more closely with modern JavaScript module standards. Additionally, a new experimental feature allows scripts in package.json
to be executed directly from the command line using the flag node --run <script-in-package-json>
.
A major highlight of Node.js 22 is its integration of Google’s V8 JavaScript engine version 12.4. This update brings with it several new capabilities, such as WebAssembly garbage collection and iterator helpers, which improve memory management and code efficiency in WebAssembly-based applications. Notably, V8’s Maglev optimizing compiler, designed to accelerate JavaScript execution, is now enabled by default on certain architectures, further boosting performance across the board.
WebSocket communication has also received significant attention in Node.js 22. The update includes a browser-compatible WebSocket implementation that is now enabled by default, eliminating the need for external dependencies to establish WebSocket connections. Previously, this functionality was hidden behind an experimental flag, but now it is fully integrated, making real-time communications more seamless for developers. The built-in WebSocket client is particularly useful for creating applications that rely on interactive, two-way communication, such as chat apps and collaborative tools.
Further enhancing performance, Node.js 22 introduces improvements to the development of AbortSignal
instances. These changes enhance efficiency in the runtime’s fetch
API and the Node.js test runner, ensuring faster execution and lower overhead. Additionally, the high water mark for streams has been increased from 16KiB to 64KiB, which offers a performance boost for applications that handle large amounts of data, although it comes with a slight increase in memory usage.
One of the more developer-friendly updates in Node.js 22 is the stabilization of watch mode. Previously considered experimental, watch mode is now fully supported, allowing Node.js processes to automatically restart whenever changes are detected in watched files. This feature simplifies the development workflow, particularly for those working on large, dynamic applications. Alongside this, Node.js 22 adds the glob
and globSync
functions to the node:fs
module, enabling developers to perform pattern matching on file paths, a common requirement in file system operations.
As Node.js 18 approaches its end-of-life in April 2025, the Node.js team is advising developers to begin planning their migration to newer versions, specifically Node.js 20 or 22. This proactive approach will ensure that applications remain supported and can take advantage of the latest performance improvements and security updates.
Node.js 22 represents a significant advancement in the runtime’s capabilities, focusing on modern JavaScript features, performance optimization, and developer convenience. With these enhancements, Node.js continues to evolve as a critical tool in the development of scalable, high-performance applications.