Nx and Lerna work together seamlessly in the same workspace.
When nx.json
is detected in the current workspace, Lerna will respect the 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.
**
When nx.json
is present, Lerna 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.
Lerna will use the task graph to determine which tasks can be run in parallel and do so automatically, so --parallel
has no effect.
:::note If you want to limit the concurrency of tasks, you can still use the concurrency global option to accomplish this. :::
Lerna 6 will automatically run dependent tasks first when necessary, so --include-dependencies
is obsolete. However,
the flag can still be used to include tasks that are not required (e.g., running the tests of all the dependent
projects).
When used with Nx, --ignore
will never cause lerna run
to exclude any tasks that are deemed to be
required task graph.
:::tip
The effects on the options above will only apply if nx.json
exists in the root with the targetDefaults
property
defined. Otherwise, they will behave just as they would with Lerna's base task runner (if useNx
is false
).
:::