Skip to content
Latchkey

npm/yarn Workspace "not found" - Fix Missing Workspace in CI

An npm/yarn workspace-scoped command targeted a workspace that does not resolve. The --workspace/workspace name does not match any package, or the package is outside the root workspaces globs so it was never registered.

What this error means

npm run build --workspace=@acme/ui fails with "No workspaces found", or yarn workspace @acme/ui build reports "Workspace not found". The name does not map to a discovered package.

npm output
npm error code EWORKSPACESNOTFOUND
npm error No workspaces found:
npm error   --workspace=@acme/ui

Diagnose it: which packages does the tool think exist?

Workspace failures are usually a globbing or topology problem: the tool cannot see a package, or it resolved a different dependency graph than you expect.

Terminal
# what the package manager sees
npm query ".workspace" 2>/dev/null || pnpm -r list --depth -1 || yarn workspaces list

# what the task runner will actually build, and in what order
npx turbo run build --dry-run=json | head -40
npx nx graph --file=graph.json

Common causes

Workspace name does not match a package

The --workspace value must match a package’s name (or its directory). A typo or using the folder name when the package name differs fails to resolve.

Package not in the workspaces globs

The root package.json workspaces array (or yarn’s workspaces) must include the package’s directory; if it does not, the package is not a workspace at all.

How to fix it

List discovered workspaces

Confirm the canonical workspace names before targeting one.

Terminal
npm query .workspace | jq '.[].name'
# yarn berry
yarn workspaces list --json

Fix the name or the globs

  1. Match --workspace/workspace to the package’s exact name.
  2. Add the package directory to the root workspaces globs if missing.
  3. Reinstall after editing globs so the workspace set is rebuilt.

How to prevent it

  • Keep the root workspaces globs covering every package directory.
  • Target workspaces by their exact name field.
  • List workspaces in CI to validate names before running scripts.

Frequently asked questions

What causes npm/yarn workspace "not found"?
There are 2 common causes: workspace name does not match a package and package not in the workspaces globs. The --workspace value must match a package’s name (or its directory).
How do I fix npm/yarn workspace "not found"?
There are 2 fixes depending on which cause you have: list discovered workspaces and fix the name or the globs. Work through them in order, since the first is the most common.
What does npm/yarn workspace "not found" actually mean?
npm run build --workspace=@acme/ui fails with "No workspaces found", or yarn workspace @acme/ui build reports "Workspace not found".
How do I stop npm/yarn workspace "not found" happening again?
Keep the root workspaces globs covering every package directory. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card