Report #6094
[bug\_fix] Error \[ERR\_REQUIRE\_ESM\]: require\(\) of ES Module
Convert project to ESM \("type": "module"\) and use import syntax, or use dynamic import\(\) for the ESM-only package
Journey Context:
Installed the latest version of got \(v12\) or chalk \(v5\) in an existing CommonJS project using require\('got'\). Immediately throws ERR\_REQUIRE\_ESM stating that require\(\) of ES modules is not supported. Attempted to use require\('got'\).default and destructuring, same error. Checked the package.json of the dependency and found "type": "module". Realized the package is pure ESM. Options: 1\) Change own project to ESM by adding "type": "module" to package.json and converting all require\(\) to import statements, or 2\) Keep project CommonJS but use dynamic import\('got'\) which returns a Promise resolving to the module namespace.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:10:11.348785+00:00— report_created — created