How to fix npm ERR! Error: ENOENT: no such file or directory, open 'package.json' in npm

npmBEGINNERMEDIUMUpdated Aug 14, 2026· 490 views

npm is being run in a directory without package.json or the path is wrong (moved repo, case mismatch, or missing checkout). Switch to the project root or recreate package.json.

Quick fix

Fixes npm ERR! Error: ENOENT: no such file or directory, open 'package.json'

pwd
ls package.json
  1. Verify you are in the project root
  2. Ensure the file exists and is tracked
  3. Fix CI/Docker workdir
  4. Create package.json if starting fresh
npm — error
pwd
ls package.json
npm ERR! Error: ENOENT: no such file or directory, open 'package.json'

What this error means

npm needs package.json in the current working directory to know what to install or run. If you run npm from the wrong folder, or package.json was deleted/ignored, the fs open call fails with ENOENT and npm exits. This also appears in CI when the working directory is mis-set, when sparse/partial checkouts skip package.json, or on case-insensitive filesystems where path casing differs from git metadata.

Typical symptoms

  • npm install/ci fails with ENOENT opening package.json
  • Running npm in a subfolder without a package.json
  • CI logs show working directory different from repo root
  • Sparse checkout or shallow clone missing package.json
  • Case mismatch between package.json and filesystem name on macOS/Windows

Common causes

  1. Running npm in the wrong directory
  2. package.json deleted, renamed, or .gitignored
  3. Partial/sparse checkout omitted package.json
  4. Misconfigured workdir in CI/Docker
  5. Case-insensitive FS mismatch (Package.json vs package.json)

How to fix "npm ERR! Error: ENOENT: no such file or directory, open 'package.json'"

1Verify you are in the project root
bash
pwd
ls package.json

If missing, cd to the directory that contains package.json.

2Ensure the file exists and is tracked
bash
git status -- package.json
ls -l package.json

Restore it if deleted or ignored.

3Fix CI/Docker workdir

Set the job working directory to the repo root (e.g., uses: actions/checkout with working-directory, or docker run -w /app).

4Create package.json if starting fresh
bash
npm init -y
5Retry install
bash
npm ci

Advanced notes

Monorepos place package.json in subpackages; ensure you run npm from the package folder or use workspaces. In CI with sparse checkout, include package.json in the sparse set. On macOS/Windows, case-insensitive filesystems can hide casing mistakes—keep the exact lowercase name. If using npm link, confirm the linked package still has its own package.json.

Frequently asked questions

What does "npm ERR! Error: ENOENT: no such file or directory, open 'package.json'" mean?
json in the current working directory to know what to install or run. json was deleted/ignored, the fs open call fails with ENOENT and npm exits. json, or on case-insensitive filesystems where path casing differs from git metadata.
How do I fix "npm ERR! Error: ENOENT: no such file or directory, open 'package.json'"?
npm is being run in a directory without package.json or the path is wrong (moved repo, case mismatch, or missing checkout). Switch to the project root or recreate package.json.
What causes "npm ERR! Error: ENOENT: no such file or directory, open 'package.json'"?
Running npm in the wrong directory package.json deleted, renamed, or .gitignored Partial/sparse checkout omitted package.json
Is the "npm ERR! Error: ENOENT: no such file or directory, open 'package.json'" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading