Node.js 20 : New Features, Updates and Improvements

May 19, 2023 Node.js 20 : New Features, Updates and Improvements
Table of Content

  1. Introduction of the Permission Model
  2. Improvements to the ESM (ECMAScript Modules) loader hooks
  3. Updated V8 engine to version 11.3
  4. Official support for ARM64 Windows
  5. The latest version of the URL parser, Ada 2.0
  6. Test_runner module marked as stable
  7. Deprecations and Removals
  8. Conclusion

Node.js, the popular open-source, cross-platform JavaScript runtime environment, has released version 20 with several exciting features and updates.

One of the most significant additions is the experimental Permission Model, which restricts access to specific resources during program execution. The ESM loader hooks now run on a dedicated thread to ensure no cross-contamination between loaders and application code. The V8 engine has been updated to version 11.3, which includes three new features to the JavaScript API. Additionally, the URL parser Ada 2.0 brings significant performance improvements to URL parsing. Node.js 20 also includes official support for ARM64 Windows. Several deprecations and removals are included, such as the runtime deprecation of url.parse() with invalid ports.

In this blog, we will take a closer look at some of the notable changes and additions to Node.js.

Introduction of the Permission Model

  • Enables developers to restrict access to specific resources during program execution
  • Prevents applications from accessing or modifying sensitive data or running potentially harmful code
  • Enabled by using the --experimental-permission flag
  • Contributed by Rafael Gonzaga

Improvements to the ESM (ECMAScript Modules) loader hooks

  • ESM hooks supplied via loaders now run in a dedicated thread, isolated from the main thread
  • Provides a separate scope for loaders and ensures no cross-contamination between loaders and application code
  • import.meta.resolve() now returns synchronously, providing better alignment with browser behavior
  • Contributed by Anna Henningsen, Antoine du Hamel, Geoffrey Booth, Guy Bedford, Jacob Smith, and Michaël Zasso

Updated V8 engine to version 11.3

  • Includes three new features to the JavaScript API: String.prototype.isWellFormed and toWellFormed, resizable ArrayBuffer and growable SharedArrayBuffer, and WebAssembly Tail Call
  • RegExp v flag with set notation + properties of strings have been added
  • Contributed by Michaël Zasso

Official support for ARM64 Windows

  • Allows for native execution on the platform
  • The MSI, zip/7z packages, and executable are available from the Node.js download site
  • The CI system was updated, and all changes are now fully tested on ARM64 Windows to prevent regressions and ensure compatibility
  • Contributed by Stefan Stojanovic

The latest version of the URL parser, Ada 2.0

  • Brings significant performance improvements to the URL parsing
  • Enhancements to the url.domainToASCII and url.domainToUnicode functions in node:url
  • Ada 2.0 has been integrated into the Node.js codebase
  • Features a significant performance boost over its predecessor, Ada 1.0.4, while also eliminating the need for the ICU requirement for URL hostname parsing
  • Contributed by Yagiz Nizipli and Daniel Lemire

Test_runner module marked as stable

  • Previously experimental, now stable and ready for production use
  • Contributed by Colin Ihrig

Deprecations and Removals

  • Runtime-deprecation of url.parse() with invalid ports
  • These URLs will emit a warning, and in future versions, they will throw an error, as the WHATWG URL API already does
  • Contributed by Rich Trott

Conclusion

Overall, Node.js version 20 comes with several notable changes and improvements that make it more stable and efficient. Developers can take advantage of the experimental Permission Model feature, the Custom ESM loader hooks running on a dedicated thread, and the updated V8 engine with several new features to the JavaScript API. Other notable changes include the stable test runner module, the latest version of the URL parser Ada 2.0, official support for ARM64 Windows, and the requirement to specify the WASI version.

It is recommended to carefully review the release notes before upgrading to ensure compatibility with existing code.


FAQs

  • Q.1: What's new on Nodejs 20?
    Node.js 20 was released on April 20, 2023. It includes a number of new features and improvements, including: Support for the ES2022 JavaScript standard A new HTTP/3 server engine A new crypto library A new debugging API A number of performance improvements
  • Q.2: What are the latest features of node JS?
    The latest feature of Node.js is support for the ES2022 JavaScript standard. This standard includes a number of new features, such as object rest and spread properties, optional chaining, and string interpolation.
  • Q.3: Which Node.js version is best?
    The best Node.js version depends on your needs. If you need the latest features and improvements, then you should use the latest version. However, if you need stability and compatibility, then you may want to use an older version.
  • Q.4: How many types of Node.js are there?
    There are two types of Node.js: LTS (Long Term Support) and Current. LTS versions are supported for a longer period of time, while Current versions are more up-to-date.
  • Q.5: Will Node.js be discontinued?
    Node.js is not going to be discontinued. It is a popular and widely used platform, and there is no indication that it will be discontinued in the near future.
  • Q.6: What is faster than node JS?
    There are a number of technologies that are faster than Node.js, including Go, Rust, and C++. However, Node.js is still a very fast platform, and it is often the best choice for developing web applications. Here are some additional details about the technologies that are faster than Node.js: Go: Go is a compiled language that is designed for speed and efficiency. It is often used for developing high-performance web applications and servers. Rust: Rust is a newer language that is also designed for speed and efficiency. It is often used for developing embedded systems and other applications where performance is critical. C++: C++ is a powerful language that has been around for many years. It is often used for developing high-performance applications, such as games and video editing software. Ultimately, the best choice for a particular application will depend on the specific requirements of that application. If speed is critical, then one of the technologies mentioned above may be a better choice than Node.js. However, if other factors, such as ease of development or community support, are more important, then Node.js may be a better choice.