Node.js 15 released: Major release of npm 7

Node.js gets a new major release. This includes a change in unhandledRejectionsand an implementation of an experimental version of the AbortControllers.

The development team around Node.js has released the major release v15. The project under the umbrella of the OpenJS Foundation receives some new features, including the experimental implementation of AbortControllers and a change to the default mode unhandledRejections. Version 7 of npm is also supported.

Experimental implementation of the AbortControllers

The AbortControlleris a global utility class that signals an abort in selected promise-based APIs. The controller is based on the AbortController Web API . The following example from the developer blog demonstrates the use of the new controller:

1234th56th7th8thconst ac = new AbortController(); ac.signal.addEventListener('abort', () => console.log('Aborted!'),{ once: true }); ac.abort(); console.log(ac.signal.aborted);  // Prints True

In the above listing, the abort event is sent when abortController.abort () is called. The AbortController triggers the Abort event only once. Event listeners that monitor the AbortSignal can use the {once: true} option to ensure that the event listener is removed as soon as the abort event is handled.

Node Packet Manager 7: Peer Dependencies installed by default

There are also some innovations in the major release of npm 7. The Packet Manager now has workspaces for the CLI. With this, several packages from a single top-level root package can be managed. Also included is a new format for package-lock.json and support for yarn.lock files. The biggest novelty is that the peer dependencies are installed by default. More information about npm 7 can be found in the related blog entry on GitHub .

Changes to the default mode for unhandledRejections

Until now, unhandledRejections were executed in warning mode by default. Node.js 15 changes the default mode to Throw . The mode can be -–unhandled-rejections=mode.changed manually using the process flag. This change was made due to user requests in a survey.

LTS – Current

With the release of Node.js 15, Node.js 14 is declared a long-term support release. v15 is given the current status. The developers are following the release policy of not assigning an LTS status to publications with an odd version number. The recommendation is accordingly to continue to use Node.js 14 in productive environments.

Node.js 15 can be downloaded from the project page, and the Node 15 release notes  can also be found there.

Leave a Reply