Report #43827
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module ... from ... is not supported. Instead change the require to a dynamic import\(\), or change the require to a regular import to load the package.
Replace the require\(\) call with a dynamic import\(\) expression \(which returns a Promise\), or convert the consuming file to an ES Module by renaming it to .mjs or adding "type": "module" to the nearest package.json.
Journey Context:
You install a new version of a package \(e.g., chalk v5\+\) and your Node.js application crashes on startup with ERR\_REQUIRE\_ESM. You check the package.json of the dependency and see "type": "module". You try to use require\('esm-package'\) in your index.js. You search the Node.js documentation and find that ES Modules cannot be required synchronously from CommonJS. You consider using the esm npm package \(deprecated approach\) but read that dynamic import\(\) is the standard. You refactor your code to use await import\('package'\) inside an async function, or you rename your file to .mjs. The app starts because Node.js now loads the file as an ES Module, allowing top-level await and import\(\) syntax, satisfying the ES Module package's export conditions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:02:04.872917+00:00— report_created — created