npm ENOENT package.json missing

npm could not find a `package.json` file in the current directory.

npm-enoent-package-json medium confidence build nodenpm

Matched signals

  • ENOENT: no such file or directory, open 'package.json'
  • ENOENT.*package.json
  • npm ERR! code ENOENT
  • npm ERR!.*package.json
  • could not read package.json
  • package.json not found

npm ENOENT package.json missing

What this failure means

npm could not find a package.json file in the current directory.

Symptoms

Faultline looks for one or more of these log fragments:

ENOENT: no such file or directory, open 'package.json'
ENOENT.*package.json
npm ERR! code ENOENT
npm ERR!.*package.json
could not read package.json
package.json not found

Diagnosis

npm expects a package.json file in the current working directory when running commands like npm install, npm ci, or npm run. The file may be missing, the CI job may be running in the wrong directory, or the repository checkout may have failed.

This error typically appears as ENOENT: no such file or directory, open 'package.json'.

Fix steps

  1. Verify the repository was checked out successfully and contains a package.json file.

  2. Check the CI job’s working-directory configuration. It may be pointing to a subdirectory that doesn’t contain package.json.

  3. If using a monorepo, ensure you’re in the correct package directory.

  4. Add a step to list files and confirm package.json exists before running npm commands:

    ls -la
    pwd
    
  5. If package.json is missing from the repository, create it with the necessary fields or restore it from version control.

Validation

  • Run ls -la package.json to confirm the file exists.
  • Re-run the npm command that previously failed.
  • Ensure the command runs in the correct directory.

Why it matters

Missing package.json prevents npm from installing dependencies or running scripts. This is a fundamental setup issue that blocks all subsequent build steps.

Prevention

  • Use explicit working-directory paths in CI configurations.
  • Add a pre‑install check that verifies package.json exists.
  • Keep repository structure consistent across branches.

Try it locally

ls -la package.json
pwd
ls -la package.json

How Faultline detects it

Use faultline explain npm-enoent-package-json to see the full playbook.

faultline analyze build.log
faultline explain npm-enoent-package-json

Generated from playbooks/bundled/log/build/npm-enoent-package-json.yaml. Do not edit directly.

Try it on your own failed log

$ faultline analyze failed.log
Want this across every CI run? Faultline Teams tracks recurring failures across all your repos and surfaces patterns in a shared dashboard.