ENOENT in Node.js — What It Means and How to Fix It
What the Node.js/npm error ENOENT means and how to resolve it.
Published October 24, 2026
ENOENT ('Error NO ENTry') means Node tried to access a file or directory that does not exist at the given path.
What it means and why it happens
Usually a wrong relative path (resolved from the working directory, not the file), a typo or a file that was not deployed.
Read the full message: it names the file and line where the problem was detected, which is the best place to start.
What you see
run the code
Error: ENOENT: no such file or directory, open 'config.json'
Practical examples
Code that triggers it
const fs = require('fs')
fs.readFileSync('config.json')The fix
const path = require('path')
const file = path.join(__dirname, 'config.json')
const data = fs.readFileSync(file, 'utf8')Check existence
if (!fs.existsSync(file)) { console.error('missing', file) }Common mistakes
- Relying on process.cwd().
- Wrong case on Linux.
- Missing files in builds and containers.
Key takeaways
- ENOENT: ENOENT ('Error NO ENTry') means Node tried to access a file or directory that does not exist at the given path.
- Read the message and the line number first.
- Fix the cause, don't just silence the error.
FAQ
Why only in production?
The working directory or file layout differs.
How do I find which line caused ENOENT?
The error message and stack trace show the file and line; start there and work backwards.