Top-5 handy lerna flags for your monorepo

pa_catch profile image trycatch ・2 min read


This filter limits the command execution scope only to packages that meet the condition. For example:

// starts a package with the name 'server'
lerna run --scope server start

// starts all packages end up on '-server'
lerna run --scope *-server start 

// you can select multiple scopes at the same time
// executes either '-server's and '-client's 'start' command
lerna run --scope *-server --scope *-client start


This one works as the previous, but in the opposite way. Basically, it excludes everything that matches the pattern or name.

// Runs 'npm audit' everywhere, but in ui-library
lerna exec --ignore ui-library npm audit

// Runs 'npm audit' everywhere, but in dev-server and dev-client packages
lerna exec --ignore dev-{server,client} npm audit


Streams apps output to your terminal. By default, lerna hides all app's internal output.

// streams interleaved output
// all messages are separated of each other by package name
lerna run --stream dev-* test

// streams whatever comes from the apps
// there's no app's name prefix, hence it's a more compact but confusing form of output
lerna run --parallel dev-* start


By default lerna tries to utilize all available CPU cores, running multiple apps simultaneously. --concurrency 1 limits threads to one, eventually making step by step tasks execution

lerna run --concurrency 1 test // tests apps' one by one


The flag applies commands to changed packages only

// Builds packages that are changed from the previous git tag
lerna run --since build

// Tests packages that are different from master branch
lerna run --since master test

Wait, what is this lerna?

Lerna is a monorepo tool, that makes you having all packages at hand. It significantly simplifies your git and versioning routine.

Read more about lerna

Posted on by:


Editor guide