Node 20: What’s New in the Latest Version of Node v20?

By:

ITS

Category:

Node.js development

Introduction
Node.js 20 is here with its latest features and new updates taking the developer community to another level of excitement. This time the development team at Node has kept the Node 20 release date on April 18, 2023. As the Node community follows the event conventions, Node.js 20 will be promoted to Long-Term Support or LTS version in October 2023. and will be supported until April 2026. But, considering What’s New in Node 20 Features and Updates, let us move ahead to learn more.

What's New in Node 20 Features and Updates

The latest Node version 20 has come up with a number of upgrades and features from the previous version in terms of performance, error handling, and many more. Let us present all these latest features and updates of Node.js 20 in detail:

Node.js Permission Model

The Permission Model feature is furnished to Node.js v20 by Rafael Gonzaga. It is an experimental mechanism introduced to enable developers to restrict access to specific resources, such as file child process spawning, system operations, and worker thread creation, simultaneously with their program running.

To access this feature, the developers must enable the –experimental-permission, which will restrict access to all the available permissions. With this feature, developers can avoid unwanted access or alteration of sensitive data or the execution of harmful code in their applications.

To learn more about the Permission Model, check out the Node.js documentation.

Custom ESM Loader Hooks are More Stable

The Custom hooks supplied via loaders (–experimental-loader=./foo.mjs) now have a dedicated thread to run, separated from the main thread delivering a different scope for loaders and ensuring no cross-contamination between loaders and application codes.

Synchronous import.meta.resolve()

Aligning with the browser behavior, the import.meta.resolve function now returns synchronously. However, the users can still define their loader resolve hooks as asynchronous or synchronous functions based on their preference. Even if there are async resolve hooks loaded, the import.meta.resolve will still return synchronously in the application code.

V8 Upgraded To 11.3

With the contribution of Michaël Zasso, a new version of the V8 engine is included in the Node.js 20. Here, the V8 engine is updated to version 11.3, a part of Chromium 113 that brings performance enhancements and new language features such as:

  • WebAssembly Tail Call
  • RegExp v flag with set notation + properties of strings
  • Resizable ArrayBuffer and growable SharedArrayBuffer
  • String.prototype.isWellFormed and toWellFormed
  • Methods that change Array and TypedArray by copy

Stable Test Runner

In Node.js version 19, the test_runner modules were experimental, but Colin Ihrig’s contribution is now in the latest Node.js version 20, updated and marked as stable. Hence, it is ready for production use. Still, some parts need stability, including reporters and code coverage.

Performance Enhancements

The Node.js team has brought some exceptional performance enhancements with the new version of Node.js. The newly formed Node.js Performance team has focused on performance enhancements since the last major release. Also, Node.js 20 has brought about several refinements to the fundamental parts of the runtime, including URL, fetch(), and EventTarget.

The cost to initiate Even Target is reduced to half, along with faster access to all subsystems using it. Also, the V8 Fast API calls offer improved performance in APIs such as URL.canParse() and timers.

Ada 2.0 Included in Node.js v20

With the contribution of Yagiz Nizipli and Daniel Lemire, the latest version of the URL parser written in C++, Ada has been included in Node.js v20 resulting in significant improvements in URL parsing performance. The upgrade in node:url enhances the url.domainToASCII and url.domainToUnicode functions. The latest Ada 2.0 integration in Node.js 20 across all aspects of the Node.js application ensures better performance than its previous version, Ada 1.0.4, and eliminates the ICU prerequisite in URL hostname parsing.

Preparing SEAs Now Requires Injecting a Blob

The Node.js team has been working on support for SEAs or the Single Executable Applications over the last year, with initial support landing recently; the team continues to make this better as the feature is still experimental. However, in Node 20, building a Single Executable App now requires injecting a blob prepared by Node.js from a JSON config rather than injecting the raw JavaScript file.

Example:
sea-config.json

{
“main”: “hello.js”,
“output”: “sea-prep.blob”
}

This writes the blob to the sea-prep.blob file.

$ node –experimental-sea-config sea-config.json
This injecting of blob presents the option to embed multiple co-existing resources into the SEAs.

Web Crypto API

Another great function in the Node.js 20 version is the coercion and validation of arguments of Web Crypto API functions as per their WebIDL definitions which is identical to the other implementations of the Web Crypto API and fosters interoperability. The goal here is to focus on interoperability with other JavaScript environments.

Official Support for ARM64 Windows

With the input of Stefan Stojanovic, ARM64 Windows is upgraded to tier 2 support. And thus, Node v20 now includes the ARM64 Windows binaries, which allows for native execution on the platform. Like other platforms, the Node.js download site provides access to the MSI, zip/7z packages, and executable files. Also, the CI system has undergone an upgrade to facilitate full testing on ARM64 Windows, thereby preventing any regressions and ensuring compatibility. Stefan Stojanovic was responsible for elevating ARM64 Windows to tier 2 support.

WASI Version Must Now Be Specified

The Node.js development team continues to progress on the WASI or Web Assembly System Interface implementation; though it is experimental, the command line option is not needed to enable WASI, which will make it easier to consume. As the team working dedicatedly on WASI gears up to preview2, several changes have been implemented to ensure compatibility with future versions. Also, a version option has been added when creating a new WASI() instance, added when creating a new WASI() instance, and in the 20.x release, specifying a version is mandatory as there is no default value. While this improves support for new versions, it requires updating any code that relied on the default version. The development team invites additional contributors interested in using WASI in Node.js or uvwasi, which is used outside the Node.js environment.

Deprecations and Removals

In Node.js 20 update, url.parse() has been deprecated at runtime with invalid ports, as denoted by [3bed5f11e0] – (SEMVER-MAJOR) in the codebase. This is because url.parse() permits URLs with non-numeric ports, which could lead to unexpected input and potentially facilitate hostname spoofing. To mitigate these risks, future versions of Node.js, starting from Node.js v20, will throw an error if such URLs are encountered. This aligns with the WHATWG URL API, which already follows this approach. As of Node.js 20, url.parse() will issue a warning for such URLs.

Miscellaneous

These were not it; there are several generic other features and upgrades that Node.js version 20 has brought up to the table:
  • Enhanced Performance with faster startup times.
  • Improved support for TLS 1.3 and more vital cryptography for secure communications.
  • Better TypeScript Support.
  • Better Debugging Experience.
  • Effective Error Handling.
To know more about the latest Node 20 features and updates, visit GitHub Node Releases or Node 20 Release Announce.

Conclusion

This is what the latest Node v20 version brings to the table. This blog post must have given you significant insight into the latest features and updates of Node 20. However, if you are a business owner using Node.js for your web application development and unsure if you should upgrade to the latest version of Node, then you can Hire Node.js development company like Bacancy to help you gain conviction and make the right choice based on your project needs and requirements.

We are trusted by over 650+ clients.
Join them by using our services and grow your business.

Get Started

SiteLogo
“At Inspire Techno Solution , our mission is to continuously innovate the best ways to train the next generation of developers and to transform the way tech education is delivered.”

Find a Career with us

Related Blogs

Node 20: What’s New in the Latest Version of Node v20? | Inspire Techno Solution

Node 20: What’s New in the Latest Version of Node v20?

The Node.js team and community always break barriers worldwide with their latest features and updates,
How to Debug Node JS Application Efficiently? | Inspire Techno Solution

How to Debug Node JS Application Efficiently?

Debugging is the skill by which we can explore these problematic situations, and with the
Node Streams: A Sneak-Peak | Inspire Techno Solution

Node Streams: A Sneak-Peak

Streams are abstract interfaces for working with data that can be read or written sequentially.