Report #68806
[bug\_fix] ERR\_REQUIRE\_ESM require\(\) of ES Module not supported
Convert the requiring file to ESM by renaming it to .mjs, or add 'type': 'module' to the project's package.json and change all require\(\) to import statements, or downgrade the dependency to a version that exports CommonJS \(e.g., chalk@4 instead of chalk@5\).
Journey Context:
A developer has an existing CommonJS project \(index.js uses const chalk = require\('chalk'\)\). They run npm install chalk to get the latest version \(v5\+\). When they run node index.js, Node throws 'Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module ... not supported'. The developer tries const chalk = await import\('chalk'\) but gets 'SyntaxError: await is only valid in async functions and the top level of modules'. They try wrapping in an async IIFE but it breaks their synchronous export pattern and other require statements. They check the chalk documentation and see that v5 is ESM-only. They realize they must either convert their entire application to ESM by adding 'type': 'module' to package.json and rewriting all require\(\) to import/export syntax, or downgrade to chalk@4 which supports CommonJS.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:58:22.050982+00:00— report_created — created