Skip to content
Latchkey

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
lerna ERR! ENOWORKSPACES workspaces need to be defined in the root package.json

Common 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

  1. Add a workspaces array to the root package.json.
  2. List the globs that cover your packages.
  3. Re-run the lerna command.
package.json
{
  "workspaces": ["packages/*"]
}

Point Lerna at pnpm workspaces

For pnpm, set the client in lerna.json so Lerna reads pnpm-workspace.yaml.

lerna.json
{
  "npmClient": "pnpm"
}

How to prevent it

  • Define workspaces in the config your package manager expects.
  • Set npmClient in lerna.json to match your package manager.
  • After upgrading to Lerna 7+, migrate off the removed useWorkspaces.

Frequently asked questions

What causes "Lerna "ENOWORKSPACES""?
npm/yarn workspaces require a workspaces array in the root package.json; without it Lerna 7+ has no package globs.
How do I fix Lerna "ENOWORKSPACES"?
Declare workspaces for npm/yarn

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card