Nodejs 21

What is new in Node.js 21 Release ?

The latest release from the Node.js team is Node.js 21. This version brings about several modifications, including updates to the V8 JavaScript engine, the stabilization of fetch and WebStreams modules, an experimental option for adjusting module defaults, the addition of a built-in WebSocket client, and improvements to the test runner. It’s worth noting that Node.js 21, being an odd-numbered release, will not be designated for long-term support (LTS).

Following are the main updates in latest release:

  • Fetch
  • WebStreams Module
  • Websocket client
  • V8 engine
  • Enhanced Test runner
  • New Flag
  • Performance focused improvements
  • Global Injection navigator

Fetch and Web Streams modules:

Within Node.js 21, the fetch and WebStreams modules have been elevated to stable status. This advancement has implications for modules such as WebStreams, FormData, Headers, Request, Response, and fetch.

WebSocket client:

Moreover, this release features an experimental WebSocket client, which can be activated using the –experimental-websocket flag. This aligns with standards compatible with browsers, streamlining JavaScript development for applications that operate on both the frontend and backend.

Update of the V8 engine:

In Node.js 21, the V8 engine has been upgraded to version 11.8, introducing enhanced performance and new language features. Noteworthy additions comprise Array grouping, ArrayBuffer.prototype.transfer, and extended-const expressions for WebAssembly. This update contributes to a decrease in reliance on external libraries.

Test runner update:

The test runner in Node.js has been improved to accommodate glob expressions when defining the –test parameter. This enhancement enables more efficient and flexible test execution, simplifying the process of running tests across multiple directories by leveraging potent glob patterns.

New Flags:

A novel flag, –experimental-default-type, has been introduced. With this flag, developers can personalize the default module system, giving them the ability to specify whether input files should be interpreted as ES modules or CommonJS.

Performance focused improvements:

The Node.js 21 release incorporates various performance-oriented improvements, particularly in areas such as URL handling, fetch functionality, streams, node:fs, and HTTP operations. These enhancements are designed to enhance the overall runtime performance.

Global Injection navigator:

The incorporation of the global navigator object in Node.js 21 improves web interoperability, granting developers access to hardware concurrency information via navigator.hardwareConcurrency.

Conclusion:

I trust that this blog has conveyed the enhancements brought about by Node.js 21 in domains such as tools, language features, libraries, and more. These advancements further solidify Node.js as a dynamic and robust JavaScript runtime environment. If you’re seeking to develop a contemporary server-side web application, consider reaching out to a Node.js development company for assistance.