Skip to content
Latchkey

npm "No workspaces found" / "workspace not found" - Fix Monorepo Install in CI

npm workspaces are declared by a workspaces glob in the root package.json. The error means npm could not match that glob to any package, or a --workspace target you named does not exist in the tree.

What this error means

npm install -w <name> or npm run build -w <name> fails with "No workspaces found" or that the named workspace does not exist. The root install may succeed while a per-workspace command cannot find its target.

npm output
npm error No workspaces found:
npm error   --workspace=@acme/api
# or
npm error No workspaces found in package.json

Common causes

The workspaces glob matches nothing in CI

A "workspaces": ["packages/*"] glob fails if the directory layout in the CI checkout differs, or the package directories lack their own package.json.

A --workspace name that does not match a package name

--workspace/-w takes the package name (or its path). A typo, or naming the directory instead of the package name, yields "workspace not found".

How to fix it

Confirm the workspaces glob and names

List the workspaces npm sees and target by exact package name.

Terminal
npm query .workspace        # list resolved workspaces
# target by the package "name", not the folder:
npm run build -w @acme/api

Verify layout and package manifests

  1. Ensure each matched directory has a valid package.json with a name.
  2. Confirm the workspaces glob matches the checked-out layout.
  3. Use npm install at the root first so workspaces are linked before per-workspace commands.

How to prevent it

  • Keep the workspaces glob aligned with the real directory layout.
  • Target workspaces by package name, not folder name.
  • Validate the workspace list with npm query .workspace in CI.

Related guides

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