Javascript Node

Node.js 22 has entered the building3 min read

#​530 — April 30, 2024

Read on the Web

Node.js 22.0 (Current) Released — The latest major version of Node is here. Note that it’s a ‘Current’ release for now, so gets all the newest features first, but is due to become Node’s main active LTS release this October. As an even numbered release, Node 22 should be around and maintained for a long time, most likely out to 2027 or so (see image above).

We’ll dig into some of what’s new with Node 22 in just a moment..

Stytch: Auth0 Alternative for AuthN, AuthZ, Fraud Prevention — Use Stytch for enterprise-grade multi-tenant B2B auth with SSO, RBAC, and SCIM. Use pre-built UIs, go headless, or integrate directly with the API. Plus, Stytch has device fingerprinting built-in to detect bots and prevent abuse. Get started free.

Stytch sponsor

So what’s new in Node 22?

V8’s Maglev compiler has been enabled by default, resulting in a performance boost for more short-lived programs.

V8 has been updated to version 12.4 (which introduces iterator helpers, Set methods, and Array.fromAsync.)

The ability to run npm scripts using node itself, e.g. node –run test

node –watch is now stable.

The previously experimental integrated WebSocket client is now enabled by default.

require(esm) support. More on that next..

Native Support for CJS/ESM Interoperability Begins in Node 22 — An overview of a new era for Node when working with both CommonJS and ECMAScript modules.

Zachary Lee

TypeScript 5.5 Beta — There’s a lot going on here (like inferred type predicates) but we’ll be focusing on it more in JavaScript Weekly. On the Node side, if you’re writing an ECMAScript module, you can now use named imports from TypeScript’s npm package.

Microsoft

JSR is Not ‘Another Package Manager’ — Node, npm and CommonJS brought a packaging standard to JavaScript, and while tools like Yarn or pnpm added their own twists to the process, Ryan says it’s time for a transformation. JSR is not ‘a new npm’ but a reshaping of how packages are distributed, designed for the ESM era.

Ryan Dahl

You Might Not Need dotenv: Node Now Natively Supports .env File Loading — This isn’t a super new feature (it’s existed since Node 20.6.0) but a handy reminder that you can trim another dependency if you have basic .env environment variable reading requirements.

Zachary Lee

📄 Web Scraping Like a Pro: Unlocking the Power of Impersonation – As well as some useful technical tips, ethics and responsibilities are also covered. Lev Gelfenbuim

🛠 Code & Tools

📺 YouTube.js: An Unofficial YouTube API Client Library — ‘InnerTube’ is an API used by YouTube’s clients, and you can use it too, although they might not like it. It runs on Node.js, Deno, and modern browsers.

LuanRT

get-windows: Get Metadata About Active and Open Windows — Get titles, ids, bounds, etc. for windows on a desktop system. Works on macOS 10.14+, Linux (though not Wayland), and Windows 7 and up.

Sindre Sorhus

browser-or-node 3.0: Figure Out Where Your Code is Running — Provides a simple way to tell if your code is currently running in a browser, in Node, in a Web Worker, or in Deno. Works with both ESM and CJS imports.

Dinesh Pandiyan

cron-schedule 5.0: Cron Parser and Scheduler — Parse and query cron style expressions in the browser, Node or Deno.

Pascal Sthamer

Odiff: A Fast Pixel-by-Pixel Image Diffing Tool and Library — Claims to provide results in milliseconds. You can use it as a CLI tool or from Node (though it’s written in OCaml, primarily). It supports PNG, JPG, and BMP, including cross-file comparisons.

Dmitriy Kovalenko

⚙️ rcompat – JS interoperability and runtime compatibility layer for servers. Terrablue

⚙️ TsumiLink – A Lava/NodeLink compatible client. Fyphen

⚙️ x-crawl – AI-assisted Web crawler library. CoderHXL

Knip 5.11.0 – Find unused files, dependencies and exports in your projects, now with caching and watching.

better-sqlite 9.6 – Neat way to use SQLite v3.45.3 from Node.

TestCafe 3.6 – Automated end-to-end web testing framework.

exiftool-vendored 26.0 – Cross-platform access to ExifTool for managing metadata in multimedia files.

JSPyBridge 1.2 – Run Python from Node or vice versa.

Slonik 41.1 – Node.js Postgres client with type safety.

ws 8.17 – Fast Node.js WebSocket library.

Pino 9.0 – Fast JSON-powered logging.

Pin It on Pinterest