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 error No workspaces found:
npm error --workspace=@acme/api
# or
npm error No workspaces found in package.jsonCommon 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.
npm query .workspace # list resolved workspaces
# target by the package "name", not the folder:
npm run build -w @acme/apiVerify layout and package manifests
- Ensure each matched directory has a valid package.json with a
name. - Confirm the
workspacesglob matches the checked-out layout. - Use
npm installat the root first so workspaces are linked before per-workspace commands.
How to prevent it
- Keep the
workspacesglob aligned with the real directory layout. - Target workspaces by package name, not folder name.
- Validate the workspace list with
npm query .workspacein CI.