ERR_REQUIRE_ASYNC_MODULE
node
module_error
ai_generated
true
Error [ERR_REQUIRE_ASYNC_MODULE]: require() of ES Module not supported with top-level await
ID: node/err-require-async-module
88%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 20 | active | — | — | — |
Root Cause
Trying to require() a module that uses top-level await. Must use import() instead.
genericWorkarounds
-
95% success Use dynamic import: const mod = await import('module')
const mod = await import('module') -
88% success Convert calling code to ESM with 'type': 'module' in package.json
'module' in package.json
Dead Ends
Common approaches that don't work:
-
Remove top-level await from the module
65% fail
May break the module's initialization logic