Skip to main content

Using Lerna (Powered by Nx) to Run Tasks

Nx and Lerna work together seamlessly in the same workspace.

When nx.json is detected in the current workspace and useNx is set to true in lerna.json, Lerna will respect nx.json configuration during lerna run and delegate to the Nx task runner.

Nx will run tasks in an order and with a concurrency that it determines appropriate based on the task graph that it creates. For more information, see Nx Mental Model: The Task Graph.

This behavior allows Nx to run tasks in the most efficient way possible, but it also means that some existing options for lerna run become obsolete.

Obsolete Options

--sort and --no-sort

Nx will always run tasks in the order it deems is correct based on its knowledge of project and task dependencies, so --sort and --no-sort have no effect.


Nx will use the task graph to determine which tasks can be run in parallel and do so automatically, so --parallel has no effect.


If you want to limit the concurrency of tasks, you can still use the concurrency global option to accomplish this.


Lerna by itself does not have knowledge of which tasks depend on others, so it defaults to excluding tasks on dependent projects when using filter options and relies on --include-dependencies to manually specify that dependent projects' tasks should be included.

This is no longer a problem when Lerna uses Nx to run tasks. Nx, utilizing its task graph, will automatically run dependent tasks first when necessary, so --include-dependencies is obsolete.


The effects on the options above will only apply if nx.json exists in the root. If nx.json does not exist and useNx is true, then they will behave just as they would with Lerna's base task runner (if useNx is false).