Skip to content
Latchkey

Yarn classic "Couldn't find package X required by Y" workspace in CI

Yarn 1 links workspace packages locally when workspaces are enabled. If a package is not part of the workspaces globs (or the root is not private), Yarn treats a local dependency as a registry package and fails to find it.

What this error means

yarn install fails with "Couldn't find package \"@acme/utils@1.0.0\" required by \"@acme/web\" on the \"npm\" registry" for a package that lives inside the repo.

yarn
error Couldn't find package "@acme/utils@^1.0.0" required by "@acme/web@1.0.0" on the "npm" registry.

Common causes

Workspaces are not enabled correctly

The root package.json lacks "private": true or the workspaces globs do not cover the package, so Yarn 1 does not link it locally.

The local version does not satisfy the range

The dependent requires ^1.0.0 but the local package is 0.9.0, so Yarn falls back to the registry and cannot find it.

How to fix it

Enable workspaces at the root

  1. Set "private": true and add workspaces globs in the root package.json.
  2. Ensure each local package version satisfies dependents' ranges.
  3. Re-run yarn install from the root.
package.json
{
  "private": true,
  "workspaces": ["packages/*", "apps/*"]
}

Align local versions with the required range

Bump the local package to a version that satisfies the dependent's range so Yarn links it instead of hitting the registry.

How to prevent it

  • Mark the workspace root "private": true.
  • Keep workspaces globs covering every local package.
  • Keep local package versions in step with dependents' ranges.

Related guides

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