How to fix "npm ERR! code ENOENT"
Tested: we reproduced this error and confirmed the fix on Node 22.23 with npm 10.9.9 and npm 9 on Ubuntu 24.04, November 29, 2026.
npm tried to open or run a file that isn’t there. The path line in the error says which one. Most of the time it’s package.json, because npm was run outside the project folder:
pwd
ls package.json
cd path/to/your-project
npm install
If the folder is right but it has no package.json yet, create one with npm init -y.
We reproduced the error four ways with npm 10.9 and npm 9: no package.json, package.json in a subfolder, a missing git and a missing program in Node’s own spawn.
Read the error
npm 10.9 printed this when we ran npm install in an empty folder:
npm error code ENOENT
npm error syscall open
npm error path /tmp/ne/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/tmp/ne/package.json'
npm error enoent This is related to npm not being able to find a file.
npm 9 printed the same lines with npm ERR! in front instead of npm error. Two lines matter:
| Line | What it tells you |
|---|---|
syscall open |
npm tried to read a file. syscall spawn means it tried to run a program |
path ... |
The exact file or program that’s missing |
Fixes by what’s missing
syscall and path |
Cause | Fix |
|---|---|---|
open and .../package.json |
You’re not in the project folder | cd into the folder that has package.json |
open and .../package.json in a new project |
The project has no package.json yet |
npm init -y |
spawn git and path git |
A dependency installs from a Git URL and Git isn’t installed or on PATH | Install Git, then open a new terminal |
open or stat on a file inside node_modules |
A broken or half-finished install | Delete node_modules and reinstall (below) |
A path in a scripts entry |
The script points at a file that doesn’t exist | Fix the path in package.json |
package.json is in a subfolder
Projects often keep the app in a subfolder such as app/, client/ or frontend/. When we ran npm start one level above the folder with package.json, npm reported ENOENT for /tmp/ne2/package.json, the folder we were in. Move into the subfolder, or run npm against it without moving:
npm --prefix app start
In VS Code, the integrated terminal opens in the folder you opened. If you opened the parent folder, cd into the project first.
spawn git ENOENT
A dependency like "x": "github:user/repo" needs Git. With Git missing from PATH, npm 10.9 printed:
npm error code ENOENT
npm error syscall spawn git
npm error path git
npm error enoent An unknown git error occurred
Install Git (on a Mac, xcode-select --install provides it, see the Command Line Tools guide), open a new terminal so the PATH updates, and check git --version before reinstalling.
A broken node_modules folder
If the path points inside node_modules, the install was interrupted or the lockfile and folder don’t match. Start clean:
rm -rf node_modules
npm install
If that fails too, npm cache verify checks npm’s download cache and removes corrupted entries. In our test it printed Cache verified and compressed. Keep package-lock.json unless you mean to update every dependency, since deleting it can change the versions you get.
ENOENT in your own Node code
The same code shows up when your program calls a command that doesn’t exist. Running spawn('notacmd') in Node 22 gave the error spawn notacmd ENOENT. Check the command name, use its full path, or make sure the program is installed on the machine that runs the code. A file path that doesn’t exist (fs.readFile) gives ENOENT: no such file or directory with the path. Paths are resolved from the folder you started Node in, not from the script’s folder, so build them from __dirname or import.meta.dirname instead.
For other npm codes (EACCES, E404, ETARGET, code 1 from a failed build script), see npm install errors. For npm error code ERESOLVE, see the ERESOLVE fix.
FAQ
What does error code ENOENT mean?
ENOENT is the operating system's "error, no entry" code: a file or folder that a program tried to open or run doesn't exist. npm passes it through and adds the path, so the path line tells you exactly what's missing.
How do I fix npm error code ENOENT?
Read the syscall and path lines. If it's open on package.json, cd into your project folder (or run npm init -y to create one). If it's spawn on a program such as git, install that program or add it to your PATH. Then run the command again.
Why does it say npm error instead of npm ERR!?
Newer npm versions changed the prefix. In our tests npm 10.9 printed npm error code ENOENT and npm 9 printed npm ERR! code ENOENT for the same problem. The codes and fixes are the same.
How do I fix npm error code EACCES?
EACCES means the file exists but you don't have permission, which is a different problem. It's most common with global installs. See our npm install errors guide for the fix that avoids sudo.
