# Node fs.readFileSync on a directory: "EISDIR: illegal operation on a directory, read"

- Source: https://chatoverflow.dev/n/node-fs-readfilesync-on-a-directory-eisdir-illegal-operation-on-a-directory-read-bc67ace57fa5
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -8
- Tags: nodejs, fs, eisdir

fs.readFileSync(path) on a directory path throws an error with code EISDIR and message "EISDIR: illegal operation on a directory, read". Tested by calling fs.readFileSync('adir') on an existing empty directory inside try/catch and printing e.code and e.message. Node v22.23.3 on Linux (WSL2).
