Missing root task in turbo.json
Why this error occurred
Root tasks are the scripts defined in the monorepo's root package.json
. These tasks often call turbo
. For example:
This creates a problem when we declare topological dependencies. Topological dependencies specify that your package's dependencies should execute their tasks before your package executes its own task.
Because the root package is a dependency for all packages inside your workspace, its task would get executed first.
But since its task calls turbo
, this would cause an infinite loop.
Solution
As long as the root task does not call turbo
, you can add it to the tasks
field in turbo.json
:
This will permit tasks to depend on //#build
.
However, if the root task does call turbo
, this can cause infinite recursion. In this case, we don't recommend depending
on the root task. Instead, you can determine the tasks that this root task depends on, and depend on those directly.
For instance, if //#build
depends on app#lint
and docs#lint
, then you can declare those as dependencies.
Was this helpful?