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.
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
- Set
"private": trueand addworkspacesglobs in the rootpackage.json. - Ensure each local package version satisfies dependents' ranges.
- Re-run
yarn installfrom the root.
{
"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
workspacesglobs covering every local package. - Keep local package versions in step with dependents' ranges.