The error, verbatim
Jump to the fix ↓npm error code ENOENT
npm error syscall open
npm error path D:\projects\app\package.json
npm error errno -4058
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'D:\projects\app\package.json'
Tested on
- Node / npm
- 24.14.0 / 11.9.0
- Re-run
- November 3: Node 24.22.2, npm 11.19.1, cross-spawn 7.0.6 on Windows Server 2025
- OS
- Windows 11 Pro; Windows Server 2025 (GitHub Actions)
- cross-spawn
- 7.0.6
Contents
The confusing one is on Windows: Error: spawn npx ENOENT, with npx installed and working in the terminal. npx is a .cmd file there, Node’s spawn doesn’t add the extension, and the old workaround of spawning npx.cmd now fails with spawn EINVAL on current Node. ENOENT itself just means “no entry”: a file or folder that doesn’t exist, named on the path line. Four situations produce it:
| What you see | Cause |
|---|---|
syscall open, path ends in package.json |
You’re in the wrong folder |
Error: spawn npx ENOENT (or spawn git, spawn python…) |
A script starts a program Node can’t find |
Cannot find module after a clean npm install |
A file: dependency points at a missing folder |
Cannot find module 'D:\…\scripts\build.js' |
A script calls a file that isn’t there |
1. Could not read package.json
The most common one. Running npm install or npm run dev in a folder without a package.json gave:
npm error code ENOENT
npm error syscall open
npm error path D:\nk-enoent\c1\package.json
npm error errno -4058
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'D:\nk-enoent\c1\package.json'
The path is where npm looked. Usually the project is one level down, the folder a git clone or create-* command just made.
Check where you are and whether that folder has a package.json:
Get-Location; Test-Path package.jsonIf it prints False, cd into the project folder (the one with package.json) and run the command again.
If a package.json exists higher up, npm uses that one instead and you get Missing script rather than ENOENT (that error, explained).
2. spawn ENOENT
A script or tool tries to start another program and Node can’t find it. For a program that isn’t installed:
Error: spawn git-lfs-nope ENOENT
On Windows there’s a trap. npx, npm and most Node CLIs are .cmd files, and Node’s spawn doesn’t add .cmd for you:
Error: spawn npx ENOENT
Adding .cmd doesn’t help on current Node. spawn('npx.cmd', …) failed straight away with spawn EINVAL: Node refuses to run .cmd and .bat files without a shell since a 2024 security fix.
If you’re writing the code, run it through the shell as one command string:
spawn('npx --version', { shell: true, stdio: 'inherit' });Or use cross-spawn, which handles Windows for you:
const spawn = require('cross-spawn');
spawn('npx', ['--version'], { stdio: 'inherit' });If it’s someone else’s tool, install the program it names (git, python…) or update the tool.
3. A file: dependency that doesn’t exist
"mylib": "file:../mylib" in package.json, with no mylib folder there. npm install didn’t complain at all: it printed added 1 package and exited 0. It had created a link to a folder that doesn’t exist, and the failure came later, at run time:
Error: Cannot find module 'mylib'
Check that every file: path in package.json points at a real folder (relative to the package.json), fix the path or create the folder, then install again:
npm install4. A script calls a missing file
"build": "node scripts/build.js" with no scripts\build.js:
Error: Cannot find module 'D:\nk-enoent\c3\scripts\build.js'
code: 'MODULE_NOT_FOUND',
The script’s path is relative to the folder you run npm run from. Check the file exists at that path, or fix the path in the script.
What I ran it on
Windows 11 Pro, Node 24.14.0, npm 11.9.0, October 18, 2026, each case in a new folder. The spawn cases ran with Node’s child_process.spawn and spawnSync, and with cross-spawn 7.0.6. Every message above is the real output.
On November 3, 2026 the four cases ran again on a clean Windows Server 2025 machine (GitHub Actions windows-latest). npm install in a folder without package.json gave syscall open and the missing path; spawn('npx') gave spawn npx ENOENT, spawn('npx.cmd') gave spawn EINVAL, and both shell: true with a command string and cross-spawn printed npx’s version, while shell: true with an argument list still printed the DEP0190 warning; the file: dependency to a missing folder again installed with exit code 0 and failed only at require; and a script calling a missing file failed when run. The script and the run are public.
— N.K., end of entry No.072