Report #6750
[bug\_fix] ERR\_REQUIRE\_ESM require\(\) of ES Module not supported
Convert your project to ESM by adding "type": "module" to package.json and changing require\(\) to import statements, or use dynamic import\(\) \(e.g., const chalk = \(await import\('chalk'\)\).default\) to load the ESM package from a CJS file.
Journey Context:
You npm install chalk@5 \(or node-fetch@3, execa@6\) and try to require it in your index.js. Node crashes with ERR\_REQUIRE\_ESM. You check the package's package.json and see "type": "module". You realize the package is pure ESM. You try changing require to import but get 'SyntaxError: Cannot use import statement outside a module'. You consider downgrading to chalk@4, but want the new features. You read the Node.js ESM docs. You either add "type": "module" to your package.json and rename files to .mjs/adjust imports, or you wrap the require in an async function and use await import\('chalk'\), which works because dynamic import can load ESM.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:49:45.492963+00:00— report_created — created