Skip to main content

ESM in Node Without a Build Step

Node 22 lets you mix CommonJS and ESM more freely. Set “type”: “module” in package.json or use the .mjs extension and import just works.The require(esm) support behind a flag in No…

April 20, 2026 JavaScript chris 1 min read Node.js

Article takeaway

Node 22 lets you mix CommonJS and ESM more freely. Set "type": "module" in package.json or use the .mjs extension and import just works.The require(esm) support behind a flag in No…

Node 22 lets you mix CommonJS and ESM more freely. Set "type": "module" in package.json or use the .mjs extension and import just works.

The require(esm) support behind a flag in Node 22 closes the last gap: CommonJS code can now load ES modules without a wrapper.

Top-level await works inside ESM, which makes startup scripts cleaner — no more wrapping everything in an async function main().

Share X / Twitter LinkedIn

Leave a comment

Related Posts