Report #53197
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module ... not supported.
Convert the importing file to ESM \(rename to .mjs or set "type": "module" in package.json\) and use static import statements, OR use dynamic import\(\) which is asynchronous and works in both CommonJS and ESM contexts.
Journey Context:
Developer installs a modern version of a popular utility \(e.g., chalk v5\+, node-fetch v3\+, strip-json-comments v5\+\) into an existing Node.js project that uses require\(\) syntax. Upon running the application, it crashes with ERR\_REQUIRE\_ESM. The developer initially tries require\(\).default and various destructuring patterns, all failing. They discover the package.json of the installed module contains "type": "module", making it ESM-only. Realizing they cannot synchronously require ESM, they refactor their entry point to .mjs and convert require\(\) to import statements, or alternatively refactor the import site to use await import\(\) inside an async function to dynamically load the ESM module.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T19:47:26.578611+00:00— report_created — created