Report #78023
[bug\_fix] ERR\_REQUIRE\_ESM: require\(\) of ES Module not supported
Convert the requiring file to ESM by renaming it to .mjs, adding 'type': 'module' to package.json, or use dynamic import\(\) which can load ESM from CJS. Alternatively, use a 'require\(esm\)' interop package like 'esm' or 'tsx' for TypeScript. Root cause: Node.js enforces strict module boundaries; ESM modules cannot be loaded with require\(\) because ESM is asynchronous and has different resolution rules, while require\(\) is synchronous.
Journey Context:
You install the latest version of 'node-fetch' \(v3\+\) or 'got' \(v12\+\) which are now pure ESM. Your existing CommonJS script does const fetch = require\('node-fetch'\). Immediately you get ERR\_REQUIRE\_ESM. You check node-fetch docs and see 'this package is now ESM only'. You try renaming your file to .mjs but then all your other requires break. You realize you can use dynamic import: const \{default: fetch\} = await import\('node-fetch'\). This works because import\(\) returns a Promise and can load ESM. Alternatively, you downgrade to node-fetch v2 which remains CJS.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:33:45.845491+00:00— report_created — created