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
- Find where package.json and yarn.lock live.
- Set working-directory on the install step to that folder.
Workflow
- name: Install
working-directory: ./web
run: yarn install --frozen-lockfileCheck out the repo first
- Place actions/checkout before any yarn step.
- Verify the files with ls before installing.
Workflow
- uses: actions/checkout@v4
- run: ls package.json yarn.lockHow 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
yarn "An unexpected error occurred: … ENOENT" - Fix in CIFix yarn "An unexpected error occurred: ENOENT: no such file or directory" in CI - a missing file/directory y…
npm ENOENT package.json Not Found in CI - Fix Missing ManifestFix "npm ERR! code ENOENT ... package.json" in CI when npm runs in a directory that has no package.json, usua…
yarn --frozen-lockfile Outdated in CI - Fix Lockfile Out of SyncFix yarn install --frozen-lockfile failures in CI when the lockfile is out of date, by regenerating and commi…