Turborepo "Could not resolve workspaces" - Fix in CI
Turborepo builds its task engine from your workspace definition. "Could not resolve workspaces" means it could not enumerate the packages - usually a missing workspaces field, an undetectable package manager, or a missing lockfile.
What this error means
Any turbo run command aborts at startup with "error preparing engine: Could not resolve workspaces". No task runs because turbo cannot build the package graph. Reproducible with the same repo layout.
× error preparing engine: Could not resolve workspaces.
╰─▶ Missing "workspaces" field in package.json, or no
pnpm-workspace.yaml / lockfile to infer packages from.Common causes
No workspaces definition
For npm/yarn the root package.json needs a workspaces array; for pnpm a pnpm-workspace.yaml. Without it turbo has no package list to resolve.
Package manager not detected
Turbo infers the package manager from the lockfile and packageManager field. If neither is present, it cannot determine how to enumerate workspaces.
Running outside the repo root
Invoking turbo from a subdirectory without a workspace root above it leaves it unable to locate the monorepo definition.
How to fix it
Declare the workspaces
Add the workspace globs for your package manager so turbo can enumerate packages.
// package.json (npm / yarn)
{ "workspaces": ["apps/*", "packages/*"] }
# pnpm-workspace.yaml (pnpm)
packages:
- "apps/*"
- "packages/*"Commit the lockfile and set packageManager
A lockfile plus an explicit packageManager field lets turbo detect the manager and resolve workspaces deterministically.
{
"packageManager": "pnpm@9.6.0"
}How to prevent it
- Keep a valid
workspacesfield (orpnpm-workspace.yaml) at the repo root. - Commit the lockfile so turbo can detect the package manager.
- Run turbo from the repo root, or pass
--cwdpointed at it.