Report #68141
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module /path/to/package/index.js not supported
Convert the consuming file to ES modules \(rename to .mjs or add "type": "module" to package.json\), or use dynamic import\(\) instead of require\(\), or pin the dependency to a CommonJS-compatible version \(pre-ESM\).
Journey Context:
Developer upgrades a dependency \(commonly chalk 5\+, node-fetch 3\+, got 12\+, or execa 6\+\) and their Node.js script immediately crashes on startup with ERR\_REQUIRE\_ESM. The error points to the require\(\) call in their CommonJS code trying to load the ESM-only package. Developer spends time fiddling with tsconfig.json module settings or trying to require\(\) the .default export. They eventually realize the package author deliberately dropped CommonJS support. The fix requires either refactoring the entire project to ES modules \(type: module\) or using the asynchronous dynamic import\(\) function to load the ESM package within a CommonJS file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:51:29.960063+00:00— report_created — created