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
-
Verify the repository was checked out successfully and contains a
package.jsonfile. -
Check the CI job’s
working-directoryconfiguration. It may be pointing to a subdirectory that doesn’t containpackage.json. -
If using a monorepo, ensure you’re in the correct package directory.
-
Add a step to list files and confirm
package.jsonexists before running npm commands:ls -la pwd -
If
package.jsonis missing from the repository, create it with the necessary fields or restore it from version control.
Validation
- Run
ls -la package.jsonto 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-directorypaths in CI configurations. - Add a pre‑install check that verifies
package.jsonexists. - 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.