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.
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.
- 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.
- 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.