Report #103403
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module ... is not supported
If you control the package, convert it to ESM or ship a dual CJS/ESM build. If you consume it from CJS code, import it dynamically with \`const \{ foo \} = await import\('esm-package'\)\` instead of \`require\('esm-package'\)\`. Root cause: Node.js disallows \`require\(\)\` of an ES module because ESM has asynchronous resolution; \`import\(\)\` returns a Promise and is the supported interop path.
Journey Context:
A developer upgrades \`node-fetch\` or \`got\` to the latest major and their CommonJS script crashes with ERR\_REQUIRE\_ESM. They search and find the package is now pure ESM. They try renaming files to \`.mjs\` and adding \`"type": "module"\` to package.json, but that cascades into every local file. They read the Node.js ESM docs and learn that \`require\(\)\` is fundamentally blocked for ESM graphs. They decide to keep the rest of the project CommonJS and use dynamic \`import\(\)\` at the call site, which lets a CJS module load an ESM package because \`import\(\)\` is available in both module systems.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:20:17.128765+00:00— report_created — created