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.
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); // 5Root 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Full-Stack Cultivation Path
Focused on sharing practical tech content about TypeScript, Vue 3, front-end architecture, and source code analysis.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
