Report #63090
[bug\_fix] ERR\_REQUIRE\_ESM require\(\) of ES Module not supported
Convert to ESM \("type": "module"\), use dynamic import\(\) for the ESM package, or downgrade to the last CommonJS version of the dependency
Journey Context:
Developer runs const chalk = require\('chalk'\) after npm install chalk \(v5\+\). Node throws ERR\_REQUIRE\_ESM because chalk 5 is pure ESM. Developer tries various require\(\) hacks and .default access patterns, all fail. They research and understand that Node treats the file as CommonJS \(.js extension, no "type": "module"\). Solutions considered: 1\) Rename file to .mjs and use import syntax \(cascading changes to whole project\), 2\) Add "type": "module" to package.json and convert all requires to imports, 3\) Use dynamic import\('chalk'\).then\(mod => ...\) to load the ESM module asynchronously from CommonJS, 4\) Downgrade to chalk ^4.1.2 \(last CJS version\). Most choose option 4 for quick fix, then plan ESM migration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T12:22:36.341631+00:00— report_created — created