Skip to content
Latchkey

yarn "An unexpected error occurred" ENOENT in CI - Fix Missing Path

An ENOENT from yarn means it tried to open a file or directory that is not there. In CI this is almost always a wrong working directory or a missing checkout.

What this error means

yarn fails with An unexpected error occurred: ENOENT: no such file or directory, naming a path such as package.json or a cache folder. It works locally from the project root.

yarn
error An unexpected error occurred:
"ENOENT: no such file or directory, open
'/home/runner/work/repo/package.json'".

Common causes

yarn runs in the wrong directory

The manifest is in a subfolder but the step runs at the repo root, so yarn finds no package.json.

The checkout is missing or incomplete

No actions/checkout, or a sparse checkout that dropped the project folder, leaves the files absent.

How to fix it

Set the correct working directory

  1. Find where package.json and yarn.lock live.
  2. Set working-directory on the install step to that folder.
Workflow
- name: Install
  working-directory: ./web
  run: yarn install --frozen-lockfile

Check out the repo first

  1. Place actions/checkout before any yarn step.
  2. Verify the files with ls before installing.
Workflow
- uses: actions/checkout@v4
- run: ls package.json yarn.lock

How to prevent it

  • Always check out the repo before yarn, set working-directory for subfolder projects, and verify the manifest exists so ENOENT surfaces a clear message early.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →