ENOENT Node.js Origin: Application & API Last updated 13 Oct 2026

Error: ENOENT: no such file or directory

A file or directory the program tried to open doesn’t exist at that path.

Exact message you may see no such file or directoryspawn ENOENTnpm ERR! enoent
Seen on: Node.js npm

Meaning

Relative paths resolve from the process’s current working directory, not the script file — so code that works from one folder fails from another. In npm, “ENOENT … package.json” means you ran npm outside the project folder.

Common causes

  • Relative path resolved from a different working directory
  • File not created/copied (build output, uploads, Docker COPY)
  • npm command run outside the project (no package.json)
  • Case mismatch on Linux
  • Executable not found when spawning (spawn git ENOENT)

⚡ Quick fix

  1. Build paths from the script location: path.join(__dirname, 'data.json')
  2. Check the exact path in the error exists
  3. Run npm in the folder with package.json
  4. For spawn X ENOENT, install X or fix PATH

Detailed fix by platform

Node.js

  1. Robust path:
    javascript
    const file = path.join(__dirname, 'config', 'settings.json');

How to diagnose

  1. Path — Exact path in the error
  2. CWD — process.cwd() at runtime
  3. Exists — Is the file present in this environment?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

0x80070002 — Windows Error 0x80070002: The system cannot find the file specified (Windows)0x800700020x80070020 — 0x80070020: The process cannot access the file because it is being used by another process (Windows)0x800700200x80070570 — Error 0x80070570: The file or directory is corrupted and unreadable (Windows)0x80070570Access to the path is denied — System.UnauthorizedAccessException: Access to the path 'x' is denied (.NET)Access to the path is…Argument list too long — bash: /bin/rm: Argument list too long (Linux)Argument list too longcommand not found — bash: command not found (Linux)command not foundCOPY failed — COPY failed: file not found in build context / "/app/x": not found (Docker)COPY failedEEXIST — Error: EEXIST: file already exists, mkdir (Node.js)EEXISTENOENT

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.