Fix it fast
Most likely: npm is looking for a file or directory that is not there, commonly package.json, a script binary, a dependency folder, or a path inside node_modules.
1. Confirm this is your error
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! spawn ENOENT 2. Check the cause
pwd
ls -la package.json
ls -la <failing-path>
npm config get prefix 3. Apply the safe fix
# If you are in the wrong folder, move to the project root and retry.
cd <project-root>
npm install
# If the missing path is inside node_modules, rebuild the install tree.
npm ci 4. Verify it works
ls -la package.json
npm install Don't use unsafe shortcuts
- Do not delete the lockfile before checking the exact missing path.
- Do not assume the package is missing from the registry.
ENOENTis usually a local filesystem path. - Do not run npm from a parent or child directory that does not contain the expected
package.json.
What npm Could Not Find
npm hit ENOENT because a required file or directory was missing, often package.json, a lockfile path, or an extracted dependency.
Manual filesystem checks
Confirm package.json exists in the current directory: ls -la package.json.
Confirm the exact package you asked for
Identify the path npm is failing on (look for the last referenced file path in the error output).
Make sure you are running npm in the right directory (the one with package.json).
If the missing path is under node_modules, remove node_modules and reinstall.
Retry after cleaning local state when safe (common:remove node_modules and retry install).
Why It Was Not Found
npm referenced a path that does not exist (wrong working directory, stale node_modules, or a broken install state).
Prove the Source Resolves Correctly Now
Re-run the original command and confirm the filesystem error no longer appears.
If this is a permission fix, confirm new files in node_modules are owned by the expected user.
How npm writes files during install
npm accepted the request well enough to look up a specific package, version, or tag, but the upstream source could not match it to a real artifact for this environment. That usually means the name, namespace, version, platform, or index or registry target is wrong, missing, or incomplete from the point of view of the failing machine.
Avoid Version and Source Drift
To prevent this, keep npm cache and project directories owned by the build user, avoid running project installs as root unless you know exactly why you need it, and ensure CI runners have enough disk space and sensible file descriptor limits.
Docs and source code
github.com/npm/cli/blob/417daa72b09c5129e7390cd12743ef31bf3ddb83/lib/commands/access.js
Open-source npm CLI code reference tied to this error code. - GitHub
} catch (err) {
if (err.code === 'ENOENT') {
throw Object.assign(new Error('no package name given and no package.json found'), {
code: 'ENOENT',
})
} else {
throw err