Report #11825
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module
Downgrade to the last CommonJS-compatible major version of the package \(e.g., [email protected] instead of chalk@5, [email protected] instead of @3\), allowing continued use of require\(\). Alternatively, convert your entire project to ES modules by adding 'type': 'module' to your package.json and converting all require\(\) to ES module import statements and module.exports to export, or use dynamic import\(\) for the specific ESM package while keeping the rest of your code CommonJS \(requires async context\).
Journey Context:
You run npm install to get the latest version of a popular utility library like chalk or node-fetch. In your existing CommonJS code, you require it as usual: const chalk = require\('chalk'\). Immediately, the process crashes with 'Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module... not supported'. You inspect the installed package's package.json and discover 'type': 'module', indicating it's ESM-only. You consider converting your entire project to ESM by renaming files to .mjs or adding 'type': 'module', but that would break your existing CommonJS ecosystem and require changing all require\(\) to import. You're stuck between downgrading the package or undergoing a major migration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:21:17.692093+00:00— report_created — created