Skip to content

The Nx command line has various subcommands and options to help you manage your Nx workspace and run tasks efficiently. Below is a complete reference for all available commands and their options. You can run nx —help to view all available options.

Available Commands

nx add

Install a plugin and initialize it.

Usage:

Terminal window
nx add <packageSpecifier>

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--packageSpecifierstringThe package name and optional version (e.g. @nx/react or @nx/react@latest) to install and initialize. If the version is not specified it will install the same version as the nx package for Nx core plugins or the latest version for other packages.
--updatePackageScriptsbooleanUpdate package.json scripts with inferred targets. Defaults to true when the package is a core Nx plugin.
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx affected

Run target for affected projects. Affected projects are projects that have been changed and projects that depend on the changed projects. See https://nx.dev/ci/features/affected for more details.

Usage:

Terminal window
nx affected

Options

OptionTypeDescriptionDefault
--allboolean⚠️ Deprecated: Use nx run-many instead
--basestringBase of the current branch (usually main).
--batchbooleanRun task(s) in batches for executors which support batches.false
--configuration, --cstringThis is the configuration to use when performing tasks on projects. (alias: -c)
--excludestringExclude certain projects from being processed.
--excludeTaskDependenciesbooleanSkips running dependent tasks first.false
--filesstringChange the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces.
--graphstringShow the task graph of the command. Pass a file path to save the graph data instead of viewing it in the browser. Pass “stdout” to print the results to the terminal.
--headstringLatest commit of the current branch (usually HEAD).
--helpbooleanShow help
--nxBailbooleanStop command execution after the first failed task.false
--nxIgnoreCyclesbooleanIgnore cycles in the task graph.false
--outputStylestringDefines how Nx emits outputs tasks logs. tui: enables the Nx Terminal UI, recommended for local development environments. dynamic-legacy: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. static: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. stream: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. stream-without-prefixes: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. (choices: dynamic-legacy, dynamic, tui, static, stream, stream-without-prefixes)
--parallelstringMax number of parallel processes [default is 3].
--runnerstringThis is the name of the tasks runner configured in nx.json.
--skipNxCache, --disableNxCachebooleanRerun the tasks even when the results are available in the cache. (alias: -disableNxCache)false
--skipRemoteCache, --disableRemoteCachebooleanDisables the remote cache. (alias: -disableRemoteCache)false
--skipSyncbooleanSkips running the sync generators associated with the tasks.false
--targets, --target, --tstringTasks to run for affected projects. (alias: -target, -t)
--tuibooleanEnable or disable the Nx Terminal UI.
--tuiAutoExitstringWhether or not to exit the TUI automatically after all tasks finish, and after how long. If set to true, the TUI will exit immediately. If set to false the TUI will not automatically exit. If set to a number, an interruptible countdown popup will be shown for that many seconds before the TUI exits.
--uncommittedbooleanUncommitted changes.
--untrackedbooleanUntracked changes.
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx connect

Connect workspace to Nx Cloud.

Usage:

Terminal window
nx connect

Options

OptionTypeDescriptionDefault
--generateTokenbooleanExplicitly asks for a token to be created, do not override existing tokens from Nx Cloud.
--helpbooleanShow help
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx daemon

Prints information about the Nx Daemon process or starts a daemon process.

Usage:

Terminal window
nx daemon

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--startbooleanNo Descriptionfalse
--stopbooleanNo Descriptionfalse
--versionbooleanShow version number

nx fix-ci

Fixes CI failures. This command is an alias for nx-cloud fix-ci.

Usage:

Terminal window
nx fix-ci [options]

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx format:check

Check for un-formatted files.

Usage:

Terminal window
nx format:check

Options

OptionTypeDescriptionDefault
--allbooleanFormat all projects.
--basestringBase of the current branch (usually main).
--excludestringExclude certain projects from being processed.
--filesstringChange the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces.
--headstringLatest commit of the current branch (usually HEAD).
--helpbooleanShow help
--libs-and-appsbooleanFormat only libraries and applications files.
--projectsstringProjects to format (comma/space delimited).
--sort-root-tsconfig-pathsbooleanEnsure the workspace’s tsconfig compilerOptions.paths are sorted. Warning: This will cause comments in the tsconfig to be lost. The default value is “true” unless NX_FORMAT_SORT_TSCONFIG_PATHS is set to “false”.
--uncommittedbooleanUncommitted changes.
--untrackedbooleanUntracked changes.
--versionbooleanShow version number

nx format:write

Overwrite un-formatted files.

Usage:

Terminal window
nx format:write

Options

OptionTypeDescriptionDefault
--allbooleanFormat all projects.
--basestringBase of the current branch (usually main).
--excludestringExclude certain projects from being processed.
--filesstringChange the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces.
--headstringLatest commit of the current branch (usually HEAD).
--helpbooleanShow help
--libs-and-appsbooleanFormat only libraries and applications files.
--projectsstringProjects to format (comma/space delimited).
--sort-root-tsconfig-pathsbooleanEnsure the workspace’s tsconfig compilerOptions.paths are sorted. Warning: This will cause comments in the tsconfig to be lost. The default value is “true” unless NX_FORMAT_SORT_TSCONFIG_PATHS is set to “false”.
--uncommittedbooleanUncommitted changes.
--untrackedbooleanUntracked changes.
--versionbooleanShow version number

nx graph

Graph dependencies within workspace.

Usage:

Terminal window
nx graph

Options

OptionTypeDescriptionDefault
--affectedbooleanHighlight affected projects.
--basestringBase of the current branch (usually main).
--excludestringExclude certain projects from being processed.
--filestringOutput file (e.g. —file=output.json or —file=dep-graph.html).
--filesstringChange the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces.
--focusstringUse to show the project graph for a particular project and every node that is either an ancestor or a descendant.
--groupByFolderbooleanGroup projects by folder in the project graph.
--headstringLatest commit of the current branch (usually HEAD).
--helpbooleanShow help
--hoststringBind the project graph server to a specific ip address.
--openbooleanOpen the project graph in the browser.true
--portnumberBind the project graph server to a specific port.
--printbooleanPrint the project graph to stdout in the terminal.
--targetsstringThe target to show tasks for in the task graph.
--uncommittedbooleanUncommitted changes.
--untrackedbooleanUntracked changes.
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number
--viewstringChoose whether to view the projects or task graph. (choices: projects, tasks)projects
--watchbooleanWatch for changes to project graph and update in-browser.true

nx import

Import code and git history from another repository into this repository.

Usage:

Terminal window
nx import [sourceRepository] [destinationDirectory]

Options

OptionTypeDescriptionDefault
--depthnumberThe depth to clone the source repository (limit this for faster git clone).
--destinationDirectory, --destinationstringThe directory in the current workspace to import into. (alias: -destination)
--helpbooleanShow help
--interactivebooleanInteractive mode.true
--refstringThe branch from the source repository to import.
--sourceDirectory, --sourcestringThe directory in the source repository to import from. (alias: -source)
--sourceRepositorystringThe remote URL of the source to import.
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx init

Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx.

Usage:

Terminal window
nx init

Options

OptionTypeDescriptionDefault
--forcebooleanForce the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.false
--helpbooleanShow help
--interactivebooleanWhen false disables interactive input prompts for options.true
--nxCloudbooleanSet up distributed caching with Nx Cloud.
--useDotNxInstallationbooleanInitialize an Nx workspace setup in the .nx directory of the current repository.false
--versionbooleanShow version number

nx list

Lists installed plugins, capabilities of installed plugins and other available plugins.

Usage:

Terminal window
nx list [plugin]

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--pluginstringThe name of an installed plugin to query.
--versionbooleanShow version number

nx login

Login to Nx Cloud. This command is an alias for nx-cloud login.

Usage:

Terminal window
nx login [nxCloudUrl]

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--nxCloudUrlstringThe Nx Cloud URL of the instance you are trying to connect to. If no positional argument is provided, this command will connect to https://cloud.nx.app.
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx logout

Logout from Nx Cloud. This command is an alias for nx-cloud logout.

Usage:

Terminal window
nx logout

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx mcp

Starts the Nx MCP server.

Usage:

Terminal window
nx mcp

nx migrate

Creates a migrations file or runs migrations from the migrations file.

  • Migrate packages and create migrations.json (e.g., nx migrate @nx/workspace@latest)
  • Run migrations (e.g., nx migrate —run-migrations=migrations.json). Use flag —if-exists to run migrations only if the migrations file exists.

Usage:

Terminal window
nx migrate [packageAndVersion]

Options

OptionTypeDescriptionDefault
--commitPrefixstringCommit prefix to apply to the commit for each migration, when —create-commits is enabled.chore: [nx migration]
--createCommits, --CbooleanAutomatically create a git commit after each migration runs. (alias: -C)false
--excludeAppliedMigrationsbooleanExclude migrations that should have been applied on previous updates. To be used with —from.false
--fromstringUse the provided versions for packages instead of the ones installed in node_modules (e.g., —from=“@nx/react@16.0.0,@nx/js@16.0.0”).
--helpbooleanShow help
--ifExistsbooleanRun migrations only if the migrations file exists, if not continues successfully.false
--interactivebooleanEnable prompts to confirm whether to collect optional package updates and migrations.false
--packageAndVersionstringThe target package and version (e.g, @nx/workspace@16.0.0).
--runMigrationsstringExecute migrations from a file (when the file isn’t provided, execute migrations from migrations.json).
--tostringUse the provided versions for packages instead of the ones calculated by the migrator (e.g., —to=“@nx/react@16.0.0,@nx/js@16.0.0”).
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx record

Records a command execution for distributed task execution. This command is an alias for nx-cloud record.

Usage:

Terminal window
nx record [options]

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx release

Orchestrate versioning and publishing of applications and libraries.

Usage:

Terminal window
nx release

Options

OptionTypeDescriptionDefault
--dry-run, --dbooleanPreview the changes without updating files/creating releases. (alias: -d)false
--groups, --group, --gstringOne or more release groups to target with the current command. (alias: -group, -g)
--helpbooleanShow help
--printConfigstringPrint the resolved nx release configuration that would be used for the current command and then exit.
--projects, --pstringProjects to run. (comma/space delimited project names and/or patterns). (alias: -p)
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx repair

Repair any configuration that is no longer supported by Nx.

Specifically, this will run every migration within the `nx` package
against the current repository. Doing so should fix any configuration
details left behind if the repository was previously updated to a new
Nx version without using `nx migrate`.
If your repository has only ever updated to newer versions of Nx with
`nx migrate`, running `nx repair` should do nothing.

Usage:

Terminal window
nx repair

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx report

Reports useful version numbers to copy into the Nx issue template.

Usage:

Terminal window
nx report

nx reset

Clears cached Nx artifacts and metadata about the workspace and shuts down the Nx Daemon.

Usage:

Terminal window
nx reset

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--onlyCachebooleanClears the Nx cache directory. This will remove all local cache entries for tasks, but will not affect the remote cache.
--onlyCloudbooleanResets the Nx Cloud client. NOTE: Does not clear the remote cache.
--onlyDaemonbooleanStops the Nx Daemon, it will be restarted fresh when the next Nx command is run.
--onlyWorkspaceDatabooleanClears the workspace data directory. Used by Nx to store cached data about the current workspace (e.g. partial results, incremental data, etc).
--versionbooleanShow version number

nx run

Run a target for a project (e.g., nx run myapp:serve:production).

You can also use the infix notation to run a target:
(e.g., nx serve myapp --configuration=production)
You can skip the use of Nx cache by using the --skip-nx-cache option.

Usage:

Terminal window
nx run [project][:target][:configuration] [_..]

Options

OptionTypeDescriptionDefault
--batchbooleanRun task(s) in batches for executors which support batches.false
--configuration, --cstringThis is the configuration to use when performing tasks on projects. (alias: -c)
--excludestringExclude certain projects from being processed.
--excludeTaskDependenciesbooleanSkips running dependent tasks first.false
--graphstringShow the task graph of the command. Pass a file path to save the graph data instead of viewing it in the browser. Pass “stdout” to print the results to the terminal.
--nxBailbooleanStop command execution after the first failed task.false
--nxIgnoreCyclesbooleanIgnore cycles in the task graph.false
--outputStylestringDefines how Nx emits outputs tasks logs. tui: enables the Nx Terminal UI, recommended for local development environments. dynamic-legacy: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. static: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. stream: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. stream-without-prefixes: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. (choices: tui, dynamic, dynamic-legacy, static, stream, stream-without-prefixes)
--parallelstringMax number of parallel processes [default is 3].
--projectstringTarget project.
--runnerstringThis is the name of the tasks runner configured in nx.json.
--skipNxCache, --disableNxCachebooleanRerun the tasks even when the results are available in the cache. (alias: -disableNxCache)false
--skipRemoteCache, --disableRemoteCachebooleanDisables the remote cache. (alias: -disableRemoteCache)false
--skipSyncbooleanSkips running the sync generators associated with the tasks.false
--tuibooleanEnable or disable the Nx Terminal UI.
--tuiAutoExitstringWhether or not to exit the TUI automatically after all tasks finish, and after how long. If set to true, the TUI will exit immediately. If set to false the TUI will not automatically exit. If set to a number, an interruptible countdown popup will be shown for that many seconds before the TUI exits.
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx run-many

Run target for multiple listed projects.

Usage:

Terminal window
nx run-many

Options

OptionTypeDescriptionDefault
--allboolean[deprecated] run-many runs all targets on all projects in the workspace if no projects are provided. This option is no longer required.true
--batchbooleanRun task(s) in batches for executors which support batches.false
--configuration, --cstringThis is the configuration to use when performing tasks on projects. (alias: -c)
--excludestringExclude certain projects from being processed.
--excludeTaskDependenciesbooleanSkips running dependent tasks first.false
--graphstringShow the task graph of the command. Pass a file path to save the graph data instead of viewing it in the browser. Pass “stdout” to print the results to the terminal.
--helpbooleanShow help
--nxBailbooleanStop command execution after the first failed task.false
--nxIgnoreCyclesbooleanIgnore cycles in the task graph.false
--outputStylestringDefines how Nx emits outputs tasks logs. tui: enables the Nx Terminal UI, recommended for local development environments. dynamic-legacy: use dynamic-legacy output life cycle, previous content is overwritten or modified as new outputs are added, display minimal logs by default, always show errors. This output format is recommended for local development environments where tui is not supported. static: uses static output life cycle, no previous content is rewritten or modified as new outputs are added. This output format is recommened for CI environments. stream: nx by default logs output to an internal output stream, enable this option to stream logs to stdout / stderr. stream-without-prefixes: nx prefixes the project name the target is running on, use this option remove the project name prefix from output. (choices: dynamic-legacy, dynamic, tui, static, stream, stream-without-prefixes)
--parallelstringMax number of parallel processes [default is 3].
--projects, --pstringProjects to run. (comma/space delimited project names and/or patterns). (alias: -p)
--runnerstringThis is the name of the tasks runner configured in nx.json.
--skipNxCache, --disableNxCachebooleanRerun the tasks even when the results are available in the cache. (alias: -disableNxCache)false
--skipRemoteCache, --disableRemoteCachebooleanDisables the remote cache. (alias: -disableRemoteCache)false
--skipSyncbooleanSkips running the sync generators associated with the tasks.false
--targets, --target, --tstringTasks to run for affected projects. (alias: -target, -t)
--tuibooleanEnable or disable the Nx Terminal UI.
--tuiAutoExitstringWhether or not to exit the TUI automatically after all tasks finish, and after how long. If set to true, the TUI will exit immediately. If set to false the TUI will not automatically exit. If set to a number, an interruptible countdown popup will be shown for that many seconds before the TUI exits.
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx show

Show information about the workspace (e.g., list of projects).

Usage:

Terminal window
nx show

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--jsonbooleanOutput JSON.
--versionbooleanShow version number

nx start-ci-run

Starts a new CI run for distributed task execution. This command is an alias for nx-cloud start-ci-run.

Usage:

Terminal window
nx start-ci-run [options]

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx sync

Sync the workspace files by running all the sync generators.

Usage:

Terminal window
nx sync

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx sync:check

Check that no changes are required after running all sync generators.

Usage:

Terminal window
nx sync:check

Options

OptionTypeDescriptionDefault
--helpbooleanShow help
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number

nx view-logs

Enables you to view and interact with the logs via the advanced analytic UI from Nx Cloud to help you debug your issue. To do this, Nx needs to connect your workspace to Nx Cloud and upload the most recent run details. Only the metrics are uploaded, not the artefacts.

Usage:

Terminal window
nx view-logs

nx watch

Watch for changes within projects, and execute commands.

Usage:

Terminal window
nx watch

Options

OptionTypeDescriptionDefault
--allbooleanWatch all projects.
--helpbooleanShow help
--includeDependentProjects, --dbooleanWhen watching selected projects, include dependent projects as well. (alias: -d)
--initialRun, --ibooleanRun the command once before watching for changes. (alias: -i)false
--projects, --pstringProjects to watch (comma/space delimited). (alias: -p)
--verbosebooleanRun watch mode in verbose mode, where commands are logged before execution.
--versionbooleanShow version number

Getting Help

You can get help for any command by adding the --help flag:

Terminal window
nx <command> --help