Field notesJul 11, 20264 min read

ERR_REQUIRE_ESM in 2026: you might just need to upgrade Node

require() of ES modules works by default since Node 22.12 and 20.19. When it still fails, it is one of two edge cases.

For years the answer to ERR_REQUIRE_ESM was “switch to import()” or “pin the last CommonJS version”. Current Node can load synchronous ES modules from require() directly.

ERR_REQUIRE_ESMErrorrequire() of ES Module not supportedCommonJS code called require() on an ESM-only package (node-fetch 3, chalk 5, nanoid 4…). Use await import(), switch your project to ESM, pin the last CJS version, or upgrade to Node ≥20.19 / 22.12 where require(esm) works.
terminal
$ node --version
v20.11.1   # too old: upgrade to 20.19+ or 22.12+

When it still fails

  • The module uses top-level await. Those cannot be loaded synchronously; use await import().
  • A bundler or test runner (older Jest, ts-node) does its own module loading and has not caught up.
Tip

Library authors: publish both builds with an exports map until your users are on 20.19+.