Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Node.js (CommonJS)
Error [ERR_REQUIRE_ESM]: require() of ES Module '...' is not supported. Instead change the require to a dynamic import().
What it means (root cause)
A dependency you require() has gone ESM-only (its package.json has "type": "module" or ships no CommonJS build), and Node refuses to load an ES module through the CommonJS require() function.
The symptom developers actually see: Error [ERR_REQUIRE_ESM]: require() of ES Module '...' is not supported. Instead change the require to a dynamic import().
Step-by-step fix
Concrete, ordered steps from the dataset. Apply them in order; each line is a verified action, not generic advice.
- 1Replace require('pkg') with an ESM import: import pkg from 'pkg' (top-level) or const pkg = await import('pkg') (dynamic import).
- 2If your project is CommonJS, rename the file to .mjs or add "type": "module" to package.json and use import syntax throughout.
- 3As a short-term workaround, pin the dependency to a version that still ships a CommonJS build.
Where this error appears
Languages, frameworks, and runtimes where this error is observed (from the 2026 DevFixPro error dataset, retrieved 2026-08-29):
Node.js 12+ (formalized during the ESM rollout). Affects any CommonJS project that pulls an ESM-only package.
How to prevent it & common questions
Practical prevention plus the questions developers ask most about this error.
What does "Error [ERR_REQUIRE_ESM]: require() of ES Module not supported" mean?
A dependency you require() has gone ESM-only (its package.json has "type": "module" or ships no CommonJS build), and Node refuses to load an ES module through the CommonJS require() function.
Which environments are affected by Error [ERR_REQUIRE_ESM]: require() of ES Module not supported?
Node.js (CommonJS)
How do I fix Error [ERR_REQUIRE_ESM]: require() of ES Module not supported?
Replace require('pkg') with an ESM import: import pkg from 'pkg' (top-level) or const pkg = await import('pkg') (dynamic import). If your project is CommonJS, rename the file to .mjs or add "type": "module" to package.json and use import syntax throughout. As a short-term workaround, pin the dependency to a version that still ships a CommonJS build.
How do I prevent Error [ERR_REQUIRE_ESM]: require() of ES Module not supported?
Track dependency module type; prefer import syntax in new code so ESM-only packages load without a rewrite.
Can I keep using require()?
Only for packages that still ship CommonJS. For ESM-only deps, use dynamic import() or move the calling file to ESM (.mjs or type:module).
Is --experimental-... needed?
No flag fixes ERR_REQUIRE_ESM on a modern Node; the fix is the import syntax, not a flag.
Related DevFixPro tools
Real, browser-only utilities on DevFixPro that help while you work through this issue. These are navigation aids, not a substitute for the fix above.
Sources & attribution
- Error records aggregated from Google Search Console query gaps (2026-05-21~2026-08-18) for devfixpro.com, plus official framework docs (MDN, Node.js docs, Python docs, Go.dev, Rust book, Oracle Java docs, Docker docs, npm docs). Source dataset retrieved 2026-08-29. License: CC BY 4.0 — attribute DevFixPro (devfixpro.com).
- Official reference: https://nodejs.org/api/esm.html#require
- All cause, environment, fix and prevention text on this page is taken verbatim from the DevFixPro 2026 error dataset. DevFixPro does not invent root causes or fixes.
How this Error [ERR_REQUIRE_ESM]: require() of ES Module not supported page is built
Each error page is generated from a single record in the DevFixPro 2026 error dataset. The meaning, root cause, environments, fix steps, prevention, and official references are copied verbatim from that dataset and its official-doc sources; related-error links are computed from the error's category and explicit peer list. No root cause or fix is invented. The retrieval date for this dataset is 2026-08-29.