
Table of Contents
Introduction
Just when we thought we had a firm grip on the ongoing Node.js version 21, the community announced the release date and activation of the latest Node.js version 22 last week. Naturally, the Node developer community met this news with great anticipation and excitement. As a result, they eagerly awaited the next iteration of this dynamic framework.
Many experts have also chimed in, expressing their enthusiasm and stating that Node 22 brings with it not just minimal but significant features and updates that are sure to enhance our development experience.
In contrast to this announcement, we couldn’t resist exploring this dynamic framework’s latest version and sharing the add-ons via this blog.
Node.js 22 has arrived
Node.js 22 has been released with many enticing new features and updates for the developer community. The official release date for Node 22 is April 24, 2024.
Next, Node v22 will transition to long-term support (LTS) in October 2024, adhering to the traditional pathway. Until then, it will remain the “Current” release for the next six months.
Let’s delve into What’s New in NodeJS 22 Features and Updates.
Node.js 22: Latest Features & Updates
The latest version of Node.js has surprised developers and business owners worldwide by introducing new features and fixing issues. There are at least 8 potential updates. For instance, it highlights the require() for ES modules, WebSocket client, updates within the V8 JavaScript engine, and more!
V8 JavaScript Engine Update to 12.4
The V8 release 12.4 now includes features like WebAssembly, Garbage Collection, and Array.fromAsync, Set methods, and iterator helpers.
Maglev Compiler
V8 has now enabled its new JIT compiler, the Maglev compiler, by default on supported architectures. This compiler helps to improve the performance of short-lived CLI programs. Specifically, it sits between the existing Sparkplug and Turbofan compilers, and the system enables it by default on supported architectures.
Support require() ESM Graphs
Support requires () the ESM graph, another significant update in the latest version of Node.js 22. ECMAScript Modules is a new JavaScript module system compared to the CommonJS module. The release includes require() support for synchronous ESM imports in the code—experimental-require-module.
When using the –experimental-require-module flag, if an ECMAScript module is loaded by require() and meets two conditions:
- It is wholly marked as an ES module with a “type”: “module” field in the closest package.json or a .mjs extension
- It is fully synchronous
In this case, require() will treat the requested module as an ES Module and return the module namespace object. In such instances, it behaves similarly to dynamic import() but runs synchronously and returns the namespace object directly.
The goal is to make the default behavior require(esm) without needing the flag. Hire a Node.js developer to experience this upgrade in your next Node.js project!
Running package.json scripts
In the latest release, a new experimental feature has been added. This feature allows the execution of scripts from the package.json using the CLI flag node –run <script-in-package-json>. It also supports the node-run test, which performs the test command inside package.json scripts.
Stream Default High Water Mark
Node.js has increased the default High Water Mark for streams from 16KiB to 64KiB. This change is set to enhance the overall performance, albeit with slightly higher memory usage. Developers or users in memory-sensitive environments can set: etDefaultHighWaterMark.
Stable Watch Mode Command Line
The Watch Mode Command Line option is now stable. In the previous Node 19 version, the Angular development team discussed the –watch feature as an exciting addition to the feature list. Now, it is stable with the Node 22 version. Additionally, other available options include:
– – watch
– – watch-path
– – watch-preserve-output
The core advantage of this feature is that developers achieve more time-efficient development because the application automatically restarts when it detects changes in the watched files.
glob and globSync
The newest release of Node v22 introduces new functionalities to the node:fsmodule. Specifically, it includes the glob and globSync functions for pattern matching. Meanwhile, your development teams can now use these features to match file paths according to specified patterns.
WebSocket
Under the experimental-websocket flag, you can now use WebSocket by default for browser compatibility. This will allow WebSocket clients to connect to Node.js without external dependencies.
AbortSignal Creation Performance Improvement
In this version, we have improved and optimized the process of creating AbortSignal instances. This enhancement will substantially boost the fetch and test runner functionalities’ performance.
Final Takeaway!
Node.js 22 marks a significant leap forward for JavaScript runtime environments. With a built-in WebSocket client, improved performance through the updated V8 engine, and a focus on modern JavaScript features like ESM, Node.js 22 empowers developers to create faster, more robust, and more efficient applications.
Whether building real-time functionalities or simply streamlining your development workflow, Node.js 22 offers compelling features that make it an attractive choice for your next project.
Contact a renowned Node.js development agency to move ahead with Node.js 22. Upgrade to Node.js 22, a worthwhile investment that positions you to take advantage of the latest advancements in JavaScript development.
AboutChetan Sheladiya
Related Posts
How to Build Modern Web Apps with Ruby on Rails?
From so many coolest things, Ruby is one of them! It was invented in Japan in the ’90s. Ruby on Rails is clean and pure...
Accepting Ruby Class Methods: Class & Instance Methods in Ruby
As a programmer, you need to write Ruby classes but for doing so it is highly important to know the exact differences between...