EISDIR
node
filesystem
ai_generated
true
Error: EISDIR: illegal operation on a directory, read
ID: node/err-fs-eisdir
97%Fix Rate
98%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 20 | active | — | — | — |
Root Cause
Attempting to read/write a directory as if it were a file.
genericWorkarounds
-
95% success Check if the path is a file: fs.statSync(path).isFile() before reading
Use lstatSync to not follow symlinks
-
97% success Fix the path to point to the actual file, not its parent directory
Common when path.join or path.resolve produces a directory path instead of file path
Dead Ends
Common approaches that don't work:
-
Adding recursive option to the read call
80% fail
fs.readFile doesn't support reading directories; recursive is for mkdir/rmdir
-
Catching the error and skipping
70% fail
The file you need isn't being read; the feature is broken
Error Chain
Frequently confused with: