Report #97145
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module ... is not supported
If the package you are requiring ships only ESM, convert your project to ESM \(\`"type": "module"\` in package.json plus \`.js\` files using \`import\`\), or use dynamic \`import\(\)\` which works from CommonJS. As a last resort, pin the dependency to the last CommonJS version. Do not attempt to patch the package with \`createRequire\`; it will fail because the ESM module cannot be evaluated by \`require\`.
Journey Context:
You upgrade a dependency and your CommonJS script starts crashing with \`ERR\_REQUIRE\_ESM\`. The stack trace points deep into \`node\_modules\` at a package whose package.json now contains \`"type": "module"\` or whose exports only list an ESM entry. You first try \`const mod = require\('pkg'\)\` and it fails. You try \`createRequire\` and it still fails because the module body contains top-level \`await\` or \`import\` statements. The real fix is either moving your own project to ESM or using \`const mod = await import\('pkg'\)\` from a CommonJS async context. Many packages now ship dual-mode, but some dropped CommonJS entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:37:31.292517+00:00— report_created — created