Lerna specify run order

You don't specify the order, you specify the topology by including a package as a dependency of another.

If package1 needs to be built before package2 you add package1 to the dependencies of package2 in the latter's package.json file. If you do not want package2 to directly depend on package1 (e.g. on production) you can still add it into devDependencies and Lerna will understand the dependency.

From lerna -h:

--sort Sort packages topologically (dependencies before dependents). Pass --no-sort to disable. [boolean] [default: true]

Note Some commands can be ran ignoring this topology, for example from lerna exec's --parallel option documentation:

completely disregards concurrency and topological sorting


You can first build your shared package and after that trigger another build.

Ex :

yarn workspace @shared run build && yarn lerna run build


lerna run build --include-dependencies --stream

--include-dependencies this flag can help

Tags:

Lerna