Node.js 22 is now available with a number of new features, such as support for “require()” for synchronous ECMAScript (ES) module graphs, which is currently an experimental feature.
When the experimental module is enabled and “require()” tries to load an ES module, if it is both explicitly marked as an ES module and is fully synchronous, the module will be loaded as an ES module with the module’s name space object returned.
According to the Node.js team, this feature is similar to dynamic “import(),” but it runs synchronously and returns the name space object directly.
This release also enables the browser implementation of WebSocket by default, allowing developers to use it without worrying about external dependencies.
Another update in this release is that Watch Mode is now stable. This feature restarts the node server when a change is made to files that are being watched.
Node.js 22 also brings support for version 12.4 of the V8 JavaScript engine, increases the default High Water Mark for streams, provides access to the Maglev Compiler by default, and more.
A full list of updates can be found in the Node.js 22 release notes.
“Node.js 22 improves a lot of small, important areas, and continues to make it easy in enterprise deployments to use JavaScript to write command line tools and for server-side scripting,” said Rafael Gonzaga, Node.js Technical Steering Committee (TSC) Member. “The broad Node.js community is critical to the continued improvement of the software and a big part of this release. Many thanks to our open source contributors for putting in the time and effort and making Node.js better with each release. Thank you also to OpenSSF and Project Alpha Omega for helping us improve Node.js security.”