node
module_error
ai_generated
true
Error: Cannot find module './X' (local file import)
ID: node/cannot-find-module-relative
95%Fix Rate
95%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 20 | active | — | — | — |
Root Cause
Local file import failed. Wrong path, missing extension, or file doesn't exist.
genericWorkarounds
-
95% success Check the file path — case-sensitive on Linux: ./Utils.js != ./utils.js
./Utils.js != ./utils.js
-
90% success For TypeScript/ESM, you may need the extension: import './file.js' (not .ts)
import './file.js' (not .ts)
Sources: https://nodejs.org/api/esm.html#mandatory-file-extensions
-
88% success Verify the file exists at the path relative to the importing file
Verify the file exists at the path relative to the importing file
Dead Ends
Common approaches that don't work:
-
Install it as an npm package
90% fail
It's a local file (./), not a package — it won't be on npm
-
Add an index.js file
65% fail
Only works if importing a directory, not a specific file
Error Chain
Leads to:
Preceded by: