> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/nrwl/nx/llms.txt
> Use this file to discover all available pages before exploring further.

# nx run

> Run a target for a project, with optional configuration and cache control.

```bash theme={null}
nx run [project][:target][:configuration] [options]
```

`nx run` executes a single named target defined in a project's configuration. Nx checks the local cache before executing the task; if a matching cache entry exists the cached output is replayed instead of re-running the command.

## Infix notation

You can omit the `run` subcommand by placing the target first:

```bash theme={null}
nx <target> <project> [options]
```

<Tabs>
  <Tab title="Full form">
    ```bash theme={null}
    nx run myapp:build
    nx run myapp:build:production
    nx run myapp:serve:development
    ```
  </Tab>

  <Tab title="Infix (shorthand)">
    ```bash theme={null}
    nx build myapp
    nx build myapp --configuration=production
    nx serve myapp
    ```
  </Tab>
</Tabs>

## Arguments

<ParamField path="project" type="string">
  The name of the project to run the target for.
</ParamField>

<ParamField path="target" type="string" required>
  The name of the target to run (e.g., `build`, `serve`, `test`, `lint`).
</ParamField>

<ParamField path="configuration" type="string">
  The named configuration to activate for the target (e.g., `production`, `development`). Equivalent to `--configuration`.
</ParamField>

## Options

<ParamField query="--configuration" type="string">
  The configuration to use when running the target. Alias: `-c`.
</ParamField>

<ParamField query="--skip-nx-cache" type="boolean" default="false">
  Rerun the task even when a matching result is available in the cache. Alias: `--disable-nx-cache`.
</ParamField>

<ParamField query="--skip-remote-cache" type="boolean" default="false">
  Disable the remote cache for this run. Alias: `--disable-remote-cache`.
</ParamField>

<ParamField query="--output-style" type="string">
  Controls how task output is displayed. Choices: `tui`, `dynamic`, `dynamic-legacy`, `static`, `stream`, `stream-without-prefixes`.
</ParamField>

<ParamField query="--graph" type="string">
  Show the task graph instead of running it. Pass a file path to save the graph to a file, or `stdout` to print to the terminal.
</ParamField>

<ParamField query="--nx-bail" type="boolean" default="false">
  Stop command execution after the first failed task.
</ParamField>

<ParamField query="--nx-ignore-cycles" type="boolean" default="false">
  Ignore cycles in the task graph.
</ParamField>

<ParamField query="--exclude-task-dependencies" type="boolean" default="false">
  Skip running dependent tasks before the specified target.
</ParamField>

<ParamField query="--skip-sync" type="boolean" default="false">
  Skip running sync generators associated with the task.
</ParamField>

<ParamField query="--batch" type="boolean">
  Run tasks in batches for executors that support batch execution.
</ParamField>

<ParamField query="--runner" type="string">
  The name of the tasks runner configured in `nx.json`.
</ParamField>

<ParamField query="--tui" type="boolean">
  Enable or disable the Nx Terminal UI. Conflicts with `--output-style`.
</ParamField>

<ParamField query="--tui-auto-exit" type="string">
  Whether to exit the TUI automatically after all tasks finish. Pass `true` to exit immediately, `false` to never auto-exit, or a number of seconds to show a countdown before exiting.
</ParamField>

<ParamField query="--verbose" type="boolean">
  Prints additional information about the command (e.g., stack traces).
</ParamField>

## Examples

<CodeGroup>
  ```bash Build a project theme={null}
  nx run myapp:build
  ```

  ```bash Build with a named configuration theme={null}
  nx run myapp:build:production
  ```

  ```bash Run tests, skipping the cache theme={null}
  nx run myapp:test --skip-nx-cache
  ```

  ```bash Serve using infix notation theme={null}
  nx serve myapp --configuration=development
  ```

  ```bash Visualize the task graph before running theme={null}
  nx run myapp:build --graph
  ```

  ```bash Save the task graph to a file theme={null}
  nx run myapp:build --graph=task-graph.json
  ```
</CodeGroup>

<Tip>
  Run `nx run myapp:build --help` to see the executor-specific options for any target.
</Tip>

## Passing options to the executor

Any flags not recognized by Nx are forwarded directly to the underlying executor. For example:

```bash theme={null}
nx run myapp:build --sourcemap --watch
```

Flags after `--` are also forwarded verbatim:

```bash theme={null}
nx run myapp:test -- --testPathPattern=auth
```
