Lerna "lerna ERR! ENOWORKSPACES" in CI
Lerna 7+ resolves packages from your package manager's workspaces config instead of the old useWorkspaces option. ENOWORKSPACES means it could not find that config: no workspaces in package.json (npm/yarn) or no pnpm-workspace.yaml with npmClient: pnpm.
What this error means
A lerna command fails with "lerna ERR! ENOWORKSPACES workspaces need to be defined in the root package.json (or pnpm-workspace.yaml)".
lerna ERR! ENOWORKSPACES workspaces need to be defined in the root package.jsonCommon causes
No workspaces field for the package manager in use
npm/yarn workspaces require a workspaces array in the root package.json; without it Lerna 7+ has no package globs.
pnpm without npmClient set to pnpm
With pnpm, packages live in pnpm-workspace.yaml; if lerna.json does not set "npmClient": "pnpm", Lerna only checks package.json and finds nothing.
How to fix it
Declare workspaces for npm/yarn
- Add a
workspacesarray to the rootpackage.json. - List the globs that cover your packages.
- Re-run the lerna command.
{
"workspaces": ["packages/*"]
}Point Lerna at pnpm workspaces
For pnpm, set the client in lerna.json so Lerna reads pnpm-workspace.yaml.
{
"npmClient": "pnpm"
}How to prevent it
- Define workspaces in the config your package manager expects.
- Set
npmClientinlerna.jsonto match your package manager. - After upgrading to Lerna 7+, migrate off the removed
useWorkspaces.