Report #100972
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module /path/node\_modules/chalk/index.js not supported. Instead change the require of index.js to a dynamic import\(\)...
Convert the importing file to ESM by adding "type": "module" to package.json or renaming it to .mjs, then use import syntax; or keep CommonJS and use const chalk = await import\('chalk'\); alternatively pin to a CommonJS-compatible version of the package.
Journey Context:
You run a script that worked last year and it blows up on require\('chalk'\). The stack trace points at your require\(\) call. You check chalk and see version 5 is ESM-only. You try const chalk = require\('chalk'\) and get ERR\_REQUIRE\_ESM. You consider downgrading to chalk 4, but that only kicks the can down the road. You rename your script to .mjs and switch to import syntax; Node now loads the ESM package correctly. If the whole project is CommonJS, you use dynamic import\(\) at the call site so you can still consume the ESM package without a full migration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-06T04:45:42.541366+00:00— report_created — created