> ## 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.

# Project configuration

> Reference for project.json and the nx property in package.json, including targets, inputs, outputs, dependsOn, tags, and all other project-level settings.

A project's configuration in Nx is assembled from three sources, each overriding the previous:

1. Tasks inferred by Nx plugins from tooling configuration files
2. Workspace `targetDefaults` in `nx.json`
3. Project-level configuration in `project.json` or `package.json`

You can inspect the merged configuration for any project with:

```bash theme={null}
nx show project <project-name> --web
```

The full machine-readable schema is at [`packages/nx/schemas/project-schema.json`](https://github.com/nrwl/nx/blob/master/packages/nx/schemas/project-schema.json).

## Configuration files

Nx merges `project.json` and the `"nx"` property in `package.json` to produce each project's final configuration. Both support identical configuration options, including executors.

<Tabs>
  <Tab title="project.json">
    ```json project.json theme={null}
    {
      "name": "mylib",
      "root": "libs/mylib",
      "sourceRoot": "libs/mylib/src",
      "projectType": "library",
      "tags": ["scope:myteam"],
      "targets": {
        "build": {
          "executor": "@nx/js:tsc",
          "inputs": ["production", "^production"],
          "outputs": ["{workspaceRoot}/dist/libs/mylib"],
          "dependsOn": ["^build"],
          "cache": true,
          "options": {
            "main": "{projectRoot}/src/index.ts",
            "tsConfig": "{projectRoot}/tsconfig.lib.json"
          },
          "configurations": {
            "production": {
              "tsConfig": "{projectRoot}/tsconfig.lib.prod.json"
            }
          }
        },
        "test": {
          "executor": "@nx/jest:jest",
          "inputs": ["default", "^production"],
          "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
          "cache": true,
          "options": {}
        }
      }
    }
    ```
  </Tab>

  <Tab title="package.json">
    ```json package.json theme={null}
    {
      "name": "mylib",
      "scripts": {
        "test": "jest"
      },
      "nx": {
        "tags": ["scope:myteam"],
        "namedInputs": {
          "production": ["default", "!{projectRoot}/**/*.spec.tsx"]
        },
        "targets": {
          "build": {
            "command": "tsc -p tsconfig.lib.json",
            "inputs": ["production", "^production"],
            "outputs": ["{workspaceRoot}/dist/libs/mylib"],
            "dependsOn": ["^build"],
            "cache": true
          }
        },
        "includedScripts": ["test"]
      }
    }
    ```
  </Tab>
</Tabs>

## Project metadata fields

### name

<ParamField body="name" type="string">
  The project's identifier used in Nx commands, e.g. `nx build mylib`. Optional
  if the project is discovered via `package.json` `"name"` field.
</ParamField>

### root

<ParamField body="root" type="string" required>
  Path to the project directory relative to the workspace root. Nx uses this
  to scope file inputs and resolve paths.
</ParamField>

### sourceRoot

<ParamField body="sourceRoot" type="string">
  Path to the project's source files relative to the workspace root. Used by
  some executors and lint rules.
</ParamField>

### projectType

<ParamField body="projectType" type="&#x22;application&#x22; | &#x22;library&#x22;">
  Classifies the project. `"application"` projects are deployable artifacts;
  `"library"` projects are reusable code consumed by other projects.
</ParamField>

### tags

<ParamField body="tags" type="string[]">
  Labels attached to the project. Used by module boundary lint rules to enforce
  dependency constraints across teams or domains.

  ```json project.json theme={null}
  {
    "tags": ["scope:myteam", "type:feature"]
  }
  ```
</ParamField>

### implicitDependencies

<ParamField body="implicitDependencies" type="string[]">
  Manually declare dependencies that Nx cannot detect from source code. Prefix
  a project name with `!` to explicitly remove a dependency. Glob patterns are
  supported.

  ```json project.json theme={null}
  {
    "implicitDependencies": ["anotherlib", "!unrelated-lib", "shop-*"]
  }
  ```
</ParamField>

### namedInputs

<ParamField body="namedInputs" type="object">
  Project-level named input definitions. These override workspace-level named
  inputs of the same name for this project's tasks only.

  ```json project.json theme={null}
  {
    "namedInputs": {
      "production": ["default", "!{projectRoot}/**/*.spec.tsx"]
    }
  }
  ```
</ParamField>

### metadata

<ParamField body="metadata.description" type="string">
  A human-readable description of the project, visible in the project graph UI.

  ```json project.json theme={null}
  {
    "metadata": {
      "description": "Shared UI component library"
    }
  }
  ```
</ParamField>

## targets

Targets define the tasks you can run against a project. Each key in `targets` becomes a runnable command: `nx <target> <project>`.

```json project.json theme={null}
{
  "targets": {
    "build": {
      "executor": "@nx/js:tsc",
      "cache": true,
      "inputs": ["production", "^production"],
      "outputs": ["{workspaceRoot}/dist/{projectRoot}"],
      "dependsOn": ["^build"],
      "options": {
        "main": "{projectRoot}/src/index.ts"
      }
    }
  }
}
```

### executor

<ParamField body="executor" type="string">
  The Nx executor that runs this target, in `"<plugin>:<executor>"` format. Use
  `"nx:run-commands"` to run an arbitrary shell command. Omit this field when
  using the `command` shorthand.
</ParamField>

### command

<ParamField body="command" type="string">
  Shorthand for running a shell command via `nx:run-commands`. Equivalent to
  setting `executor: "nx:run-commands"` and `options.command`.

  ```json project.json theme={null}
  {
    "targets": {
      "build": {
        "command": "tsc -p tsconfig.lib.json"
      }
    }
  }
  ```
</ParamField>

### options

<ParamField body="options" type="object">
  Default options passed to the executor or command. The available properties
  depend on the executor being used.
</ParamField>

### configurations

<ParamField body="configurations" type="object">
  Named sets of option overrides. Activate a configuration with
  `nx build mylib --configuration=production`.

  ```json project.json theme={null}
  {
    "targets": {
      "build": {
        "executor": "@nx/js:tsc",
        "options": {
          "tsConfig": "{projectRoot}/tsconfig.lib.json"
        },
        "configurations": {
          "production": {
            "tsConfig": "{projectRoot}/tsconfig.lib.prod.json"
          }
        }
      }
    }
  }
  ```
</ParamField>

### defaultConfiguration

<ParamField body="defaultConfiguration" type="string">
  The configuration name used when no `--configuration` flag is supplied.
</ParamField>

### cache

<ParamField body="cache" type="boolean">
  Whether Nx should cache task results. Set to `true` to enable caching for a
  target (required as of Nx 17).

  ```json project.json theme={null}
  {
    "targets": {
      "test": {
        "cache": true
      }
    }
  }
  ```
</ParamField>

<Warning>
  Disabling caching for a target prevents it from being distributed via Nx
  Agents. Any targets that depend on it will also fail to distribute.
</Warning>

### inputs

<ParamField body="inputs" type="array">
  File sets, environment variables, and other inputs used to compute the cache
  hash. If any input changes, the task re-runs. Accepts named input strings and
  input objects.

  ```json project.json theme={null}
  {
    "targets": {
      "build": {
        "inputs": [
          "production",
          "^production",
          { "externalDependencies": ["vite"] }
        ]
      }
    }
  }
  ```
</ParamField>

See the [Inputs reference](/reference/inputs) for all input types.

### outputs

<ParamField body="outputs" type="string[]">
  Paths where the target writes file artifacts. Nx caches and restores these
  paths. Supports `{projectRoot}` and `{workspaceRoot}` tokens, glob patterns,
  and negation patterns.

  ```json project.json theme={null}
  {
    "targets": {
      "build": {
        "outputs": [
          "{workspaceRoot}/dist/libs/mylib",
          "{workspaceRoot}/build/libs/mylib/main.js"
        ]
      }
    }
  }
  ```
</ParamField>

Default output locations Nx caches when no `outputs` are specified:

* `{workspaceRoot}/dist/{projectRoot}`
* `{projectRoot}/build`
* `{projectRoot}/dist`
* `{projectRoot}/public`

### dependsOn

<ParamField body="dependsOn" type="array">
  Tasks that must complete before this target starts. Use string shorthand or
  the object form for advanced control.

  | Shorthand    | Meaning                                                           |
  | ------------ | ----------------------------------------------------------------- |
  | `"^build"`   | Run `build` on all project dependencies first                     |
  | `"build"`    | Run `build` on the current project first                          |
  | `"build-*"`  | Run all targets matching the pattern on the current project first |
  | `"^build-*"` | Run all matching targets on all dependencies first                |
</ParamField>

<Tabs>
  <Tab title="String shorthand">
    ```json project.json theme={null}
    {
      "targets": {
        "build": { "dependsOn": ["^build"] },
        "test": { "dependsOn": ["build"] }
      }
    }
    ```
  </Tab>

  <Tab title="Object form">
    ```json project.json theme={null}
    {
      "targets": {
        "build": {
          "dependsOn": [
            {
              "dependencies": true,
              "target": "build",
              "params": "ignore"
            }
          ]
        }
      }
    }
    ```

    The `params` field controls whether CLI flags are forwarded to dependency
    targets: `"ignore"` (default) or `"forward"`.
  </Tab>

  <Tab title="Specific projects">
    ```json project.json theme={null}
    {
      "targets": {
        "build": {
          "dependsOn": [
            { "projects": ["is-even", "is-odd"], "target": "pre-build" }
          ]
        }
      }
    }
    ```
  </Tab>
</Tabs>

### continuous

<ParamField body="continuous" type="boolean" default="false">
  Mark this target as a long-running process that never exits (e.g. a dev
  server). Dependent tasks start without waiting for this target to finish.
  Available in Nx 21+.

  ```json project.json theme={null}
  {
    "targets": {
      "serve": {
        "continuous": true
      }
    }
  }
  ```
</ParamField>

### parallelism

<ParamField body="parallelism" type="boolean" default="true">
  Whether this target may run in parallel with other targets on the same
  machine. Set to `false` for targets that require exclusive access to a shared
  resource such as a port. Available in Nx 19.5+.

  ```json project.json theme={null}
  {
    "targets": {
      "e2e": {
        "parallelism": false
      }
    }
  }
  ```
</ParamField>

<Info>
  `parallelism: false` only prevents concurrent execution on a single machine.
  With Nx Agents, the same target can still run on multiple agents simultaneously
  because agents do not share resources.
</Info>

### syncGenerators

<ParamField body="syncGenerators" type="string[]">
  Sync generators to run before this target executes to ensure configuration
  files are up to date. Available in Nx 19.8+.

  ```json project.json theme={null}
  {
    "targets": {
      "build": {
        "syncGenerators": ["some-plugin:my-sync-generator"]
      }
    }
  }
  ```
</ParamField>

### metadata

<ParamField body="metadata.description" type="string">
  A human-readable description of what this target does, visible in
  `nx show project` output.

  ```json project.json theme={null}
  {
    "targets": {
      "build": {
        "metadata": {
          "description": "Compile TypeScript and bundle for production"
        }
      }
    }
  }
  ```
</ParamField>

## How target configuration is merged

Nx builds a target's effective configuration in this order, with later sources overriding earlier ones:

<Steps>
  <Step title="Inferred tasks">
    Nx plugins inspect tooling config files (e.g. `vite.config.ts`,
    `jest.config.ts`) and infer task definitions automatically.
  </Step>

  <Step title="targetDefaults in nx.json">
    Workspace-wide defaults keyed by executor or target name are merged on top
    of inferred tasks. Only one matching default is applied per target.
  </Step>

  <Step title="Project-level configuration">
    Settings in `project.json` or `package.json` override both inferred tasks
    and `targetDefaults`.
  </Step>
</Steps>

## package.json integration

Nx automatically includes any `package.json` referenced by your package manager's workspace configuration. Scripts defined in `scripts` become Nx targets.

### Limiting which scripts become targets

Use `includedScripts` to opt in to specific scripts as Nx targets, ignoring the rest:

```json package.json theme={null}
{
  "name": "my-library",
  "scripts": {
    "build": "tsc",
    "postinstall": "node ./tasks/postinstall"
  },
  "nx": {
    "includedScripts": ["build"]
  }
}
```
