nx/docs/shared/recipes/node/wait-for-tasks.md
Jack Hsu 66eaf2fc74
docs(misc): remove /nx-api pages (#31453)
This PR removes the `/nx-api` pages from `nx-dev`. They are already
redirected from `/nx-api` to either `/technologies` or
`/reference/core-api` URLs.

e.g. `/nx-api/nx` goes to `/reference/core-api/nx` and `/nx-api/react`
goes to `/technologies/react/api`

**Changes**:
- Remove old `nx-api.json` from being generated in
`scripts/documentation/generators/generate-manifests.ts` -- this was
used to generate the sitemap
- Remove `pages/nx-api` from Next.js app since we don't need them
- Remove workaround from link checker
`scripts/documentation/internal-link-checker.ts` -- the angular
rspack/rsbuild and other workarounds are gone now that they are proper
docs in `map.json`
- Update Powerpack/Remote Cache reference docs to exclude API documents
(since they are duplicated in the Intro page) --
`nx-dev/models-document/src/lib/mappings.ts`
- All content in `docs` have been updated with new URL structure

**Note:** Redirects are already handled, and Claude Code was used to
verify the updated `docs/` URLs (see report below). The twelve 404s
links were updated by hand.

## Verification Report

https://gist.github.com/jaysoo/c7863fe7e091cb77929d1976165c357a
2025-06-04 16:57:01 -04:00

34 lines
1.7 KiB
Markdown

---
title: Wait for Tasks
description: Learn how to ensure dependent tasks are completed before running a primary task in Nx, using dependsOn property or the waitUntilTargets option for Node executors.
---
# Wait for Tasks
There are a couple ways to ensure that a set up task has been run before you run a particular task.
The most common solution is to use the [`dependsOn` property](/reference/project-configuration#dependson). This works regardless of what executor the task is using. Once the dependent tasks have completed, the primary task will start. Reference the [project configuration documentation](/reference/project-configuration#dependson) for more information.
If you are using the `@nx/js:node` executor, you can also use the [`waitUntilTargets` option](/technologies/typescript/api/executors/node#waituntiltargets) of that executor. Once the dependent tasks emit something to the console, the primary task will start.
## waitUntilTargets
If you have a Node api called `api` and a database project called `db`, you may want to run `nx serve db` any time you run `nx serve api`.
To set that up, edit the `api` app's `project.json` file:
```json {% fileName="/apps/api/project.json" %}
{
"targets": {
"serve": {
"executor": "@nx/js:node",
"options": {
"waitUntilTargets": ["db:serve"]
}
}
}
}
```
With this configuration in place, if you run `nx serve api`, Nx will first run `nx serve db`. The `nx serve api` process will not be launched until `nx serve db` outputs something to the console. Then both processes will continue executing in parallel. When you kill the main process, both the `db` and `api` processes will be stopped.