Report #100068
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module ... not supported
If your project is CommonJS, either convert the consuming file/package to ESM \(\`"type": "module"\` in package.json and use \`import\` syntax\), or use dynamic \`import\(\)\` for the ESM-only dependency. Do not try to \`require\(\)\` an ESM-only package; Node enforces this boundary. Alternatively, pin an older version of the dependency that still ships CommonJS, or ask the maintainer for dual-mode support.
Journey Context:
You \`npm install chalk@5\` \(or \`node-fetch@3\`, \`execa@7\`, etc.\) in an old CommonJS project and your script crashes with \`ERR\_REQUIRE\_ESM\`. You try \`const chalk = require\('chalk'\)\`, then you try destructuring, then you rename the file to \`.mjs\` but other \`require\(\)\` calls break. The real issue is that the package is now ESM-only: its \`package.json\` contains \`"type": "module"\` and Node's module loader refuses to load it via \`require\(\)\`. Converting your entry point to ESM, or using \`const \{ default: chalk \} = await import\('chalk'\)\`, resolves it because dynamic \`import\(\)\` can load ESM from a CommonJS context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-01T04:35:54.488876+00:00— report_created — created