ERR_MODULE_NOT_FOUND
node
esm
ai_generated
true
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/utils' imported from /app/index.js
ID: node/err-module-not-found-esm
94%Fix Rate
96%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 20 | active | — | — | — |
Root Cause
ESM import cannot find the module — missing file extension in import path.
genericWorkarounds
-
96% success Add the .js file extension to imports: import { fn } from './utils.js'
ESM requires explicit file extensions unlike CJS
Sources: https://nodejs.org/api/esm.html#mandatory-file-extensions
-
85% success Configure TypeScript or bundler to handle extension rewriting
In tsconfig: moduleResolution: 'nodenext' adds extensions in output
Dead Ends
Common approaches that don't work:
-
Adding 'type': 'commonjs' to package.json
70% fail
Switches the entire project back to CJS; breaks ES imports
-
Using require() instead of import
65% fail
Mixing module systems causes more problems
Error Chain
Frequently confused with: