Node.js 20 is released

Node.js 20 is released. Its not LTS release but Node.js 20 LTS version will be released in Oct 2023. Therefore I thought to explain what new features are coming in new release. So before its LTS version released we will get a good grip or understanding for the new changes coming in Node.js 20.

Node.js 20 has following main updates,

  • Experimental Permission Model
  • Synchronous import.meta.resolve()
  • Stable Test Runner
  • V8 JavaScript engine updated to 11.3, adds 5 new features
  • Single Executable Apps allows the distribution of Node.js apps systems without Node.js installed
  • Ada to 2.0

Experimental Permission Model

Node.js provides a simple but powerful permission model that allows developers to control access to system resources such as files, network interfaces, and environment variables. But with the new permission model, it will allow to restrict access to a specific resource during program execution. This model will improve the security process. In the first phase permission model is coming along with following features,

  • Restrict access to the file system (read and write)
  • Restrict access to child_process
  • Restrict access to worker_threads
  • Restrict access to native addons

Synchronous import.meta.resolve()

The import.meta.resolve() method simplifies the process of writing scripts that are not dependent on their specific location or the module configuration of the web application. As per the behavior in web browsers, this method now returns synchronously, even when there are asynchronous resolve hooks loaded. For application code, import.meta.resolve() will always return synchronously.

Stable Test Runner

In Node.js 19, the test runner was considered experimental, but it has since become stable. This tool enables the development of JavaScript tests. The test runner that is now stable comes equipped with the essential elements needed for creating and executing tests, which include:

  • Structuring test files using describe, it/test, and hooks
  • Mocking functionality
  • Watch mode for continuous testing
  • Running multiple test files in parallel using node –test command.

V8 JavaScript engine updated to 11.3

Node.js is driven by the V8 engine, which executes and interprets your JavaScript code within the Node environment. Node.js stays up-to-date with the latest changes in the V8 JavaScript engine. The newest version of Node.js boasts five additional functionalities, which are:

  • String.prototype.isWellFormed and toWellFormed methods
  • Array and TypedArray methods that modify by copying
  • Resizable ArrayBuffer and expandable SharedArrayBuffer
  • v flag for regular expressions, along with set notation and string properties
  • WebAssembly Tail Call feature

Single Executable Apps

Distributing Node.js applications without requiring the installation of Node.js is made possible by Single Executable Apps.

Ada to 2.0

One of the specific updates in Node.js 20 is the inclusion of Ada version 2.0, which is a fast and specification-compliant URL parser written in C++. In order to increase the speed of accessing all subsystems using EventTarget, the initialization cost has been reduced by 50%. Moreover, V8 Fast API calls have been utilized to enhance the performance of certain APIs such as URL.canParse() and timers.

To read more about the Node.js 20 new features, following is the page updating by NodeJs team.

Leave a Reply