Report #14323
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module /path/to/node\_modules/chalk/index.js from /path/to/script.js not supported.
Convert the consuming file to ES modules by renaming it to .mjs, or add "type": "module" to the nearest package.json, or replace the require\(\) call with a dynamic import\(\) which returns a Promise: const chalk = await import\('chalk'\).
Journey Context:
Installed a modern package like chalk 5\+, node-fetch 3\+, or got 12\+ which are pure ES modules \(type: module in their package.json\). Your existing CommonJS code uses const chalk = require\('chalk'\). Node.js 12\+ throws ERR\_REQUIRE\_ESM because ES modules cannot be synchronously required by CommonJS. You try deleting node\_modules and using --experimental-modules flag which doesn't help. Searching reveals the package author purposely moved to ESM only. The fix requires either migrating your entire project to ES modules \(type: module\) or using the dynamic import\(\) function which is asynchronous and returns a Promise, requiring refactoring of your synchronous code to async.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:16:47.628820+00:00— report_created — created