EISDIR 🟩 Node.js

Error: EISDIR: illegal operation on a directory, read

A file API (readFile, writeFile, createReadStream) was given a directory path.

Seen on: Node.js

Meaning

Path building mistakes (missing file name, trailing slash) or a config value pointing at a folder.

Common causes

  • Path missing the file name
  • Config/env var pointing to a directory
  • Globs resolving to folders

⚡ Quick fix

  1. Log the resolved path
  2. Check fs.statSync(p).isFile() before reading
  3. Use fs.readdir for directories

Detailed fix by platform

Node.js

  1. if (fs.statSync(p).isDirectory()) throw new Error(p + ' is a directory');

How to diagnose

  1. Path — What path was used?
  2. Type — File or directory?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.