Node.js v22.12 LTS Enables Native require(esm) Support by Default

Node.js v22.12.0 LTS now activates require(esm) out‑of‑the‑box, letting require() load native ES modules without the experimental flag, while also introducing resizable ArrayBuffer behavior and updated root certificates, with guidance on usage, checks, and known pitfalls.

Full-Stack Cultivation Path
Full-Stack Cultivation Path
Full-Stack Cultivation Path
Node.js v22.12 LTS Enables Native require(esm) Support by Default

require(esm) Support

Node.js v22.12.0 (LTS) adds a significant update: the require(esm) feature is enabled by default, allowing the traditional require() function to load native ES modules without the previously required --experimental-require-module flag.

In earlier versions (v20.x and early v22.x), developers had to enable this capability via the command‑line flag --experimental-require-module. Starting with v23.x the feature is always on, and the v22.12 release removes the need for the flag altogether.

Although still experimental, the feature now works without extra flags. When a require() call first encounters a native ES module, Node.js emits an experimental warning unless the module resides under a node_modules path. The warning can be suppressed by launching Node.js with --no-experimental-require-module. The current status can be inspected programmatically via process.features.require_module or by using the module-sync export condition.

export function greet() {
  console.log("Hello, ESM!");
}

Running the following code in Node.js v22.12 loads the ES module without error:

const { greet } = require('./esmModule');
greet(); // prints: Hello, ESM!

Developers can also check the feature flag at runtime:

if (process.features.require_module) {
  console.log('require(esm) is enabled');
}

Potential Issues

Modules that use top‑level await may throw ERR_REQUIRE_ASYNC_MODULE unless they are loaded from a path containing node_modules. The experimental warning is also emitted in such cases.

Note: Using this API may cause compatibility problems in your Node.js applications.

Previously this problem only appeared when jumping to a major version (v23), but the change in v22.12 means it can surface in minor upgrades, so developers should verify their code promptly.

Other Notable Changes

Resizable ArrayBuffer Support

When a resizable ArrayBuffer is used to create a Buffer, the Buffer 's length now tracks the underlying ArrayBuffer size.

const ab = new ArrayBuffer(10, { maxByteLength: 20 });
const buffer = Buffer.from(ab);
console.log(buffer.byteLength); // 10
ab.resize(15);
console.log(buffer.byteLength); // 15
ab.resize(5);
console.log(buffer.byteLength); // 5

Root Certificate Update to NSS 3.104

The bundled NSS library has been updated to version 3.104 (released alongside Firefox 131.0 on 2024‑10‑01). New root certificates include:

FIRMAPROFESIONAL CA ROOT-A WEB

TWCA CYBER Root CA

SecureSign Root CA12

SecureSign Root CA14

SecureSign Root CA15

This change simplifies the publishing of native ESM packages for NPM authors, reducing the risk of breaking CommonJS consumers.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Node.jsArrayBufferES modulesrequire(esm)NSS certificates
Full-Stack Cultivation Path
Written by

Full-Stack Cultivation Path

Focused on sharing practical tech content about TypeScript, Vue 3, front-end architecture, and source code analysis.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.