API Reference

Lerna

Monorepo management tool built on Nx that versions packages, publishes to npm, and runs scripts across workspaces.

Official Documentation ↗
CompatibilityThis documentation covers version v10.1.1. Check the official docs for the latest API surface.

Installation

npmnpm install --save-dev lerna
pnpmpnpm add -D lerna

Methods

Overview

Lerna is a monorepo manager built on Nx that versions and publishes packages and runs scripts across workspaces with topological ordering. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.

Core APIs

  • lerna run — Runs an npm script in each package that contains it, with topological ordering by default.
  • lerna publish — Bumps versions and publishes changed packages to the registry in dependency order.
  • lerna changed — Lists packages that have changed since the last release, useful for release scripts.

Example

# run tests only in packages matching a name pattern
lerna run test --scope="@acme/*" --stream

Notes

Internal dependencies must be listed under dependencies to get correct publish ordering. Lerna v8 delegates task running to Nx.

Verification

Run lerna changed after a local commit and confirm the listed packages match the ones you actually edited.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://lerna.js.org/docs/api-reference/commands · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:39.108Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

FAQ

Does Lerna still support fixed versioning?
Yes. Use lerna version with the default fixed mode, or set version: "independent" in lerna.json for per-package versions.
How does Lerna v8 relate to Nx?
Lerna is now powered by Nx for task running and caching, so tasks can share the Nx cache and graph.
How do I control publish order?
Lerna publishes in topological order derived from package dependencies; declare internal deps in dependencies, not devDependencies, to be ordered correctly.