npm ERR! code ENOENT: What It Means and How to Fix It
ENOENT means 'no such file or directory'. In npm it usually means you're in the wrong folder, there's no package.json, a script points at a missing file, or node_modules is broken. How to read the error and fix each cause.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/you/projects/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/you/projects/package.json'
ENOENT stands for "Error NO ENTry" — a system error meaning a file or folder that was expected doesn't exist. The most useful line is path: it tells you exactly which file npm was looking for. (How to read an error message)
Cause 1: you're not in the project folder (most common)
If the missing path ends in package.json, npm is looking in the wrong place. npm commands must run in the folder containing package.json.
pwd # where am I?
ls # is package.json here?
cd my-app # go into the project
npm install
After cloning or unzipping a project, the files are usually in a subfolder. (The terminal for beginners)
Cause 2: there's no package.json yet
Starting a brand-new project? Create one:
npm init -y
(What are npm and package.json?)
Cause 3: a script refers to a missing file
npm ERR! enoent spawn ... ENOENT
Error: Cannot find module '/app/dist/server.js'
Your npm start runs node dist/server.js, but dist/ doesn't exist because you haven't built yet. Run the build first:
npm run build
npm start
Check the "scripts" in package.json to see what each command runs. (npm run dev vs build vs start)
Cause 4: a broken or half-finished install
ENOENT errors pointing inside node_modules usually mean a corrupted install — often after an interrupted npm install, switching branches, or changing Node versions. Reinstall cleanly:
rm -rf node_modules
npm install
On Windows PowerShell: Remove-Item -Recurse -Force node_modules. (node_modules explained)
If it persists, clear npm's cache too:
npm cache clean --force
Cause 5: spawn git ENOENT or spawn python ENOENT
npm ERR! enoent spawn git ENOENT
A package's install step tried to run a program — git, python, make — that isn't installed or isn't on your PATH. Install it, open a new terminal, and retry. (Command not found and the PATH)
Cause 6: path problems on Windows
- Paths with spaces or special characters sometimes break older tools. Moving the project to a simple path like
C:\dev\my-apphelps. - Very long paths — enable long paths in Git and Windows, or keep projects near the drive root.
- Running a script written for Mac/Linux (
rm -rf,cp) in Command Prompt. Use cross-platform tools likerimraf, or run in Git Bash or WSL. (What is WSL?)
Cause 7: case sensitivity in production
import './Components/Header' works on macOS and Windows (case-insensitive) but fails on Linux servers where the folder is components. That shows up as ENOENT or "Cannot find module" only after deploying. Match the exact case. (Cannot find module, Works locally but not in production)
Quick checklist
- Read the
pathline — what file is missing? - Is it
package.json? →cdinto the project. - Is it a build output? → run the build.
- Is it inside
node_modules? → reinstall. - Is it
spawn <program>? → install that program.
EasySpawn builds and runs your app in a consistent Linux environment, so path, case and missing-tool surprises show up during development rather than on deploy day. See how it works or join the waitlist.
Related: "Cannot Find Module" · What Is node_modules? · npm EACCES Permission Denied · File Paths Explained
Keep reading
"Python Is Not Recognized as an Internal or External Command": How to Fix It
On Windows, "'python' is not recognized as an internal or external command, operable program or batch file" (or "pip is not recognized") means Windows can't find Python on your PATH. How to check whether Python is installed, use the py launcher, add Python to PATH, turn off the Microsoft Store alias, and fix pip.
The grep Command: Search Files and Logs Like a Pro
grep searches text for lines that match a pattern — in files, whole folders, or the output of another command. The examples you'll actually use: case-insensitive search, recursive search, line numbers, context around matches, counting, excluding folders, regex, and grepping logs, plus ripgrep.