# npm ERR! enoent Could not read package.json (ENOENT: no such file or directory): how to fix it

> npm error code ENOENT with Could not read package.json means npm opened package.json in the folder it took for the project, and there was no such file. Usually npm ran in the wrong folder: the app lives in a subfolder of a monorepo, a CI step or a Dockerfile runs npm before the file is there, a stray node_modules in a parent folder misleads npm, or package.json was never committed. The path line of the error names the folder npm looked in.

Source: https://livops.dev/en/guides/error-npm-enoent-could-not-read-package-json

By Livops team, the people who build and run Livops. Updated 3 December 2026.

The error, as npm 10.6 and later print it (here npm ran in `/app`, which has no `package.json`):

```text
npm error code ENOENT
npm error syscall open
npm error path /app/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/app/package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
```

Older npm prints the same lines with `npm ERR!` in front:

```text
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /app/package.json
npm ERR! errno -2
npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
```

npm up to 10.5 wrote its log through `npmlog`, whose error level is labelled `ERR!`[4][5]; from 10.6 npm prints the level name itself, `error`[6][2]. The message is the same. This page explains how npm decides where to look, lists the causes from the most common, gives the fix for each, and shows where to set the app's folder when it is deployed on Livops.

## What does the error mean?

Before most commands, npm decides which folder is the project. Starting at the current folder, it walks up the tree looking for a folder that has a `package.json` file or a `node_modules` folder, and treats the first one it finds as the current directory; if it finds none, it uses the current folder[7][8]. Then it opens `package.json` there. When that read fails, npm adds `Could not read package.json:` in front of the system's error[3], and for `ENOENT` it prints the `code`, `syscall`, `path` and `errno` lines and the hint that npm could not find a file[1].

**Read the path line first.** It is the exact file npm tried to open. Compare it with where your `package.json` really is:

- **The path is your current folder**: npm ran in a folder without `package.json` (causes 1, 2, 4, 5).
- **The path is a folder above your project**: a parent folder has a `node_modules` folder and npm stopped there (cause 3).
- **The path is inside a container**, such as `/app/package.json`: the file was not copied there before npm ran (cause 6).

npm uses the error's `errno` as its exit code[1]. In our run of npm 11 on macOS that was 254, so a CI log may only say `exited with code 254`. The real cause is in the lines above it.

## Causes, most common first

### 1. npm ran in the wrong folder

The simplest case: a terminal opened in your home folder, a `cd` with a typo, or a script that runs from somewhere else. Check where you are and whether the file is there:

```sh
pwd
ls package.json
npm prefix        # the folder npm will treat as the project
```

`npm prefix` prints the closest parent folder that contains a `package.json` file or a `node_modules` folder[9]. **Fix:** `cd` into the folder that holds `package.json`, or pass it to npm. On the command line, `--prefix` makes non-global commands run in the folder you name[8]:

```sh
npm --prefix ./my-app install
```

### 2. The app is in a subfolder of a monorepo

The repository root has no `package.json`; each app has its own:

```text
repo/
├── apps/
│   ├── web/
│   │   └── package.json
│   └── api/
│       └── package.json
└── README.md
```

`npm install` at the root fails with `path /repo/package.json`. **Fix:** run npm in the app's folder:

```sh
cd apps/web && npm ci && npm run build
# or, without changing folder
npm --prefix apps/web ci
npm --prefix apps/web run build
```

If the root does have a `package.json` that declares the apps as **workspaces**, you can run a script inside one of them from the root with `--workspace`, and `cd` into the folder works as well[10]:

```sh
npm run build --workspace=apps/web
```

**In GitHub Actions**, point the steps at the app's folder: set `working-directory` on a step, or `defaults.run.working-directory` for every `run` step of a job or the whole workflow[11]:

```yaml
jobs:
  build:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: apps/web
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm run build
```

### 3. A node_modules folder in a parent directory

Because npm stops at the first folder with a `package.json` **or** a `node_modules` folder[7], a stray `node_modules` above your project changes where npm looks. A common one is `~/node_modules`, left behind by an `npm install` run in the home folder. npm then treats your home folder as the project, and the error's path is `~/package.json`, not your project's.

**Fix:** if the parent folder is not a project, delete its stray `node_modules`. If your project folder simply has no `package.json` yet, create one there (`npm init -y`) so npm stops at your folder.

### 4. package.json is not in the repository

Your machine has the file; the clone in CI or on the server does not, because it was never added or `.gitignore` drops it. Check both:

```sh
git ls-files package.json         # prints nothing if the file is not committed
git check-ignore -v package.json  # prints the .gitignore rule that excludes it
```

`git check-ignore -v` prints the matching exclude pattern together with the path[12]. **Fix:** remove the rule, then commit the file with its lockfile:

```sh
git add package.json package-lock.json
git commit -m "Add package.json"
```

### 5. The file name has the wrong case

npm opens `package.json`, in lower case. A file named `Package.json` or `package.JSON` is found on macOS and Windows, whose file systems usually ignore case, and is missing on Linux, where CI and servers run. Rename it through Git so the rename is committed:

```sh
git mv Package.json package.json
```

### 6. A Dockerfile runs npm before package.json is copied

`WORKDIR` sets the folder for every `RUN`, `CMD`, `ENTRYPOINT`, `COPY` and `ADD` that follows it, and a `COPY` destination that does not start with `/` is relative to that folder[13]. So npm fails with `path /app/package.json` when it runs in `/app` before anything was copied there, or when the files were copied somewhere else:

```dockerfile
FROM node:22
WORKDIR /app
RUN npm ci            # fails: nothing has been copied into /app yet
COPY . .
```

Copy the manifest first, then install, then copy the rest:

```dockerfile
FROM node:22
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
CMD ["npm", "start"]
```

Two more places to look. `COPY` sources are relative to the build context[13], so when you build from a monorepo root, copy from the app's folder (`COPY apps/web/package.json apps/web/package-lock.json ./`). And a `.dockerignore` file excludes files from the build context[14]: if it lists `package.json` or a pattern that matches it, the file never reaches the builder.

## How to confirm the fix

Reproduce what the server does: a fresh clone, then npm in the folder the server uses.

```sh
git clone <your repo> /tmp/check && cd /tmp/check/apps/web
npm prefix          # must print this folder
npm ci
npm run build
```

If `npm prefix` prints this folder and `npm ci` gets past reading `package.json`, the ENOENT is fixed. A missing lockfile is a different error: `npm ci` says it can only install with an existing `package-lock.json`.

## On Livops

- **Tell Livops which folder holds the app.** When you create a project from a GitHub repository that is a monorepo, specify the folder the project lives in, for example `apps/web`. In the cabinet the field is **Project folder** (the docs call it the Root folder); empty means the top level, and for a repository a **Browse** button lets you pick the folder instead of typing it. When the form fills the field itself, it says *We found the project in this folder.* The same field is in the project's settings, if the first choice was wrong. See [Ways to deploy](https://livops.dev/en/docs/deploy).
- **livops.json goes in the repository root or the project folder.** Every field is optional, and what you leave out comes from the detected value; the install, build and start commands are also in **Settings → Install**, **Settings → Build** and **Settings → Start**. See [Frameworks and livops.json](https://livops.dev/en/docs/frameworks).
- **If your app comes up as a static site.** Livops reads the code to detect the framework, and if nothing is detected, it serves the folder as a static site. If a Node app deploys as a static site, check that the project folder is the one that holds its `package.json`.
- **A Dockerfile is used when there is one.** If the repository has a `Dockerfile`, Livops builds with it, so cause 6 applies to your deploy too.
- **Where the error shows.** If the install fails, the deploy stops as `install_failed`; if the build command fails, as `build_failed`. The npm error itself is in the build log. See [Install failed](https://livops.dev/en/docs/error-install) and [Build failed](https://livops.dev/en/docs/error-build).
- **The assistant can fix the folder.** It can change the project folder, and the build and start commands, for you. With auto mode on, fixing the project folder is one of the small actions it applies without waiting for your click. See [Assistant](https://livops.dev/en/docs/assistant).

A static site is free; an app costs **39 credits a month** (39,000 so'm); see [Pricing](https://livops.dev/en/docs/pricing).

A build that ends with `npm error code 1` has its real error above that line: see [npm error code 1](https://livops.dev/en/guides/error-npm-exit-code-1). If npm finds `package.json` but the app then fails with `Cannot find module`, see [Cannot find module](https://livops.dev/en/guides/error-node-cannot-find-module).

## Questions

**Which folder did npm look in?**

The one in the path line of the error: the path is that folder plus /package.json. npm starts at the current folder and walks up to the nearest folder with a package.json or a node_modules folder, and uses the current folder if it finds neither. Run npm prefix to print the folder npm will use.

**Is npm error the same as npm ERR!?**

Yes, the same message from different npm versions. npm up to 10.5 printed its errors with npm ERR!, and npm 10.6 and later print npm error. The code, path and enoent lines are the same.

**My app is in a subfolder. Do I have to cd into it?**

Either cd into the folder that holds package.json, or tell npm where it is with --prefix, for example npm --prefix apps/web run build. If the repository root has its own package.json with workspaces, npm run build --workspace=apps/web runs the script inside that workspace.

**Why does the error name a folder above my project?**

npm walks up from the current folder and stops at the first folder that has a package.json or a node_modules folder. A stray node_modules in a parent folder, for example in your home folder, makes npm treat that parent as the project, and it has no package.json.

**It works on my machine. Why does CI or the server fail?**

The server has only what is in the repository. A package.json that .gitignore drops, or one that was never added, exists only on your machine. A file named Package.json also works on macOS and Windows, where file names usually ignore case, and fails on Linux.

**Should I run npm init to make the error go away?**

Only if this folder really is a new project. npm init creates an empty package.json without your dependencies or scripts, so the next command fails differently. If the app has a package.json somewhere else, run npm in that folder instead.

## Sources

1. [npm CLI source — lib/utils/error-message.js](https://raw.githubusercontent.com/npm/cli/latest/lib/utils/error-message.js). Checked 3 December 2026.
2. [npm CLI source — lib/utils/display.js](https://raw.githubusercontent.com/npm/cli/latest/lib/utils/display.js). Checked 3 December 2026.
3. [@npmcli/package-json source — lib/read-package.js](https://raw.githubusercontent.com/npm/package-json/main/lib/read-package.js). Checked 3 December 2026.
4. [npm CLI v10.5.0 source — lib/utils/display.js](https://raw.githubusercontent.com/npm/cli/v10.5.0/lib/utils/display.js). Checked 3 December 2026.
5. [npmlog source — lib/log.js](https://raw.githubusercontent.com/npm/npmlog/main/lib/log.js). Checked 3 December 2026.
6. [npm CLI v10.6.0 source — lib/utils/display.js](https://raw.githubusercontent.com/npm/cli/v10.6.0/lib/utils/display.js). Checked 3 December 2026.
7. [npm Docs — folders](https://docs.npmjs.com/cli/v12/configuring-npm/folders/). Checked 3 December 2026.
8. [npm Docs — config (prefix)](https://docs.npmjs.com/cli/v12/using-npm/config/). Checked 3 December 2026.
9. [npm Docs — npm prefix](https://docs.npmjs.com/cli/v12/commands/npm-prefix/). Checked 3 December 2026.
10. [npm Docs — workspaces](https://docs.npmjs.com/cli/v12/using-npm/workspaces/). Checked 3 December 2026.
11. [GitHub Docs — Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax). Checked 3 December 2026.
12. [Git — git-check-ignore documentation](https://git-scm.com/docs/git-check-ignore). Checked 3 December 2026.
13. [Docker Docs — Dockerfile reference (WORKDIR, COPY)](https://docs.docker.com/reference/dockerfile/). Checked 3 December 2026.
14. [Docker Docs — Build context](https://docs.docker.com/build/concepts/context/). Checked 3 December 2026.
