Report #100521
[bug\_fix] ERR\_REQUIRE\_ESM require\(\) of ES Module not supported
Convert the requiring file to ESM \(rename to \`.mjs\` or add \`"type": "module"\` and use \`import\`\), or pin the dependency to a CommonJS-compatible version. For dynamic cases use \`await import\('module'\)\` inside a CJS file; it returns a Promise that resolves the ESM namespace.
Journey Context:
Your CommonJS project does \`const chalk = require\('chalk'\)\` and after an \`npm update\` you get \`ERR\_REQUIRE\_ESM require\(\) of ES Module not supported\`. Confused, you check \`node\_modules/chalk/package.json\` and see \`"type": "module"\` or \`"exports"\` pointing only to ESM. The package went ESM-only in a major version. You initially try \`require\('chalk/package.json'\)\` or deep paths, which fail because the exports field blocks them. You consider downgrading to \`chalk@4\`, which works but leaves you on an old version. The better path: you refactor the file to ESM with \`import chalk from 'chalk'\`, update \`package.json\` to \`"type": "module"\`, and convert sibling \`require\(\)\` calls. For files you can't convert yet, you use \`const \{ default: chalk \} = await import\('chalk'\)\` which Node allows from CJS. The root cause is that Node forbids synchronous \`require\(\)\` of an ES module because ESM has async load semantics.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T04:39:05.624873+00:00— report_created — created