Node.JS 18 Released

Muhammad Arshad
BITLogix
Published in
6 min readApr 21, 2022

All you need to know about Nodejs 18

A Quick Intro

Node.js is a cross-platform, open-source back-end JavaScript runtime environment that uses the V8 engine to execute JavaScript code outside of a web browser.The basic idea behind Node.js is to employ non-blocking, event-driven I/O to keep data-intensive real-time applications that run across dispersed devices light and efficient.

Node.js v18?

It’s that time of year again, when Node.js 18.0 is released by the Node.js community. The most wonderful news is that in October 2022, this version will be elevated to long-term support (LTS). The codename for the release will be ‘Hydrogen’ once it is promoted to long-term support. Support for Node.js 18 will last until April 2025. Before that, we need the rest of the ecosystem to test it out and provide feedback to the community. This will allow us to address any issues ahead of time and ensure that the release, ecosystem, and customers are all ready when it is released.

Deprecation and Removals

“(SEMVER-MAJOR) fs: runtime deprecate string coercion in fs.write, fs.writeFileSync (Livia Medeiros) #42607(SEMVER-MAJOR) dns: remove dns.lookup and dnsPromises.lookup options type coercion (Antoine du Hamel) #41431(SEMVER-MAJOR) process: runtime deprecate multipleResolves (Benjamin Gruenbaum) #41896(SEMVER-MAJOR) stream: remove thenable support (Robert Nagy) #40773(SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life (Tobias Nießen) #41479 “ __Node Document

Okay Now let’s see What’s New?

Experimental Fetch:

The most exciting news is that version 18 will finally provide native fetch functionality in Node.js. For the longest time, Node did not contain support for fetch, which is a highly standard API on the web for conducting HTTP requests or any other type of network request, and Node did not support it by default. If you wanted to make an HTTP request, you had to either use third-party tools or write the request from scratch. The implementation comes from undici and is inspired by node-fetch which was originally based upon undici-fetch. The implementation strives to be as close to spec-compliant as possible, but some aspects would require a browser environment and are thus omitted.

The API will remain experimental until further test coverage is introduced and the contributors have verified that the API implements as much of the requirements as is practicable.

Because JavaScript is utilised in so many areas, this is actually wonderful news for the entire ecosystem.It’s utilised on the web, in Node.js, and in Cloudflare workers, for example.
Cloudflare workers are currently shipping with their own proprietary implementation fetch. You’ll ought to install some few packages until you can use Node.There is a version for the web, so there is a lot of inconsistency along the route. Node is now providing formal support for this. That is, any environment that runs JavaScript on servers is almost certainly running Node. If it isn’t running Deno, it will support fetch by default, and because this is the team, the real team, doing it.

This tweet by Matteo Collina indicates that in Node.js version 18, which is the next version of Node and even numbers are LTS versions as well.

Tweet on Node.js V18

Example:

fetch API

Undici Library in Node.js:

If we look at this issue closely, we can see that Node utilised or primarily ported a library called Undici. What exactly is this library? It’s officially produced by the Node team, however it’s really an HTTP 1.1 full-fledged client written entirely in Node JS.

Experimental test runner:

The node:test module facilitates the creation of JavaScript tests that report results in TAP format. To access it:

import test from ‘node:test’;

This module is only available under the node: scheme. __Node Document

Node.js 18 features a test runner that is still in development.It is not meant to replace full-featured alternatives such as Jest or Mocha, but it does provide a quick and straightforward way to execute a test suite without any additional dependencies.

It provides TAP output, which is extensively used, and makes the output easier to consume.

More information may be found in the community blog post and the Node.js API docs

Example:

testing framework

community blog post

Note: The test runner module is only available using the node: prefix. The node: prefix denotes the loading of a core module. Omitting the prefix and importing 'test' would attempt to load a userland module. __Node Documents

Platform support:

As with other major releases, this one upgrades the minimum supported levels for systems and tooling needed to create Node.js. Node.js includes pre-built binaries for a variety of platforms. The minimum toolchains for each major release are evaluated and raised if needed.

· Red Hat Enterprise Linux (RHEL) 8 now builds prebuilt binaries for Linux which are compatible with Linux distributions based on glibc 2.28 or later, such as Debian 10, RHEL 8, and Ubuntu 20.04.

· MacOS 10.15 or later is now required for prebuilt binaries.

  • For AIX the minimum supported architecture has been raised from Power 7 to Power 8.

Due to issues with creating the V8 dependencies in Node.js, prebuilt binaries for 32-bit Windows will not be accessible at first. With a future V8 upgrade, we hope to restore 32-bit Windows binaries for Node.js 18.

According to Node.js BUILDING.md file

Supported platforms is current as of the branch/release to which it belongs

Input

Node.js relies on V8 and libuv. We adopt a subset of their supported platforms.

Strategy

There are three support tiers:

  • Tier 1: These platforms represent the majority of Node.js users. The Node.js Build Working Group maintains infrastructure for full test coverage. Test failures on tier 1 platforms will block releases.
  • Tier 2: These platforms represent smaller segments of the Node.js user base. The Node.js Build Working Group maintains infrastructure for full test coverage. Test failures on tier 2 platforms will block releases. Infrastructure issues may delay the release of binaries for these platforms.
  • Experimental: May not compile or test suite may not pass. The core team does not create releases for these platforms. Test failures on experimental platforms do not block releases. Contributions to improve support for these platforms are welcome.

V8 version 10.1

The V8 engine has been updated to version 10.1 as part of Chromium 101. The following new features are added in Node.js 17.9.0 over the previous version:

findLast() & findLastIndex():

With the findLast() and findLastIndex() methods, This use case is easily and ergonomically solved.They perform identically to their find() and findIndex() equivalents, with the exception that they begin their search at the end of the Array or TypedArray.

Example:

A big thank you

The Node.js releaser team, which created and supervised the Node.js 18 release, would like to thank everyone who contributes to Node.js releases.The Node.js project has a vast cast of contributors working on it, and each release is the culmination of their efforts.

Wrapping up

All of the new features and updates are detailed in this community post here.Check out the project website to learn more about the Node.js community and how you can help.

--

--