Nx Commands
The Nx CLI provides many commands. They are organized here into commands that:
There is also a section for separate commands that can create a new Nx workspace for you.
If the command that you pass to Nx is not one of the keywords listed below, it will try to interpret the command as if it were a task. So Nx will parse your command in the following ways and execute the first syntax that is valid.
nx [built-in-command] [...arguments]
nx [task-name-for-root-project] [...arguments]
nx [task-name] [project-name] [...arguments]
Modify Code
These commands modify your codebase in some way.
init
Adds Nx to any type of workspace. It installs nx, creates an nx.json
configuration file and optionally sets up remote caching.
โฏ
nx init
nx init
Add to Existing Monorepo
Add to Any Project
Migrate from Angular CLI
add
Install a plugin and initialize it.
โฏ
nx add my-plugin
generate
Runs a generator that creates and/or modifies files based on a generator from a plugin.
โฏ
nx generate @nx/react:component libs/my-lib/src/lib/my-component
migrate
Creates a migrations file or runs migrations from the migrations file.
โฏ
nx migrate latest
โฏ
nx migrate --run-migrations
import
Import code and git history from another repository into this repository.
โฏ
nx import https://github.com/myorg/inventory-app.git apps/inventory
โฏ
nx import ../inventory-app apps/inventory
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.
โฏ
nx repair
sync
Run all sync generators
โฏ
nx sync
โฏ
nx sync:check
format
Overwrite un-formatted files or check for un-formatted files
โฏ
nx format
โฏ
nx format:check
Run Tasks
These commands run tasks on your code.
run
Run a target for a project
โฏ
nx run my-app:build
โฏ
nx build my-app
run-many
Run target for multiple listed projects
โฏ
nx run-many --target=build
affected
Run target for affected projects
โฏ
nx affected --target=build
exec
Executes any command as if it was a target on the project
1{
2 "scripts": {
3 "build": "nx exec -- node ./my-custom-build.js"
4 }
5}
6
watch
Watch for changes within projects, and execute commands
โฏ
nx watch --projects=assets -- nx build assets
release
Orchestrate versioning and publishing of applications and libraries
โฏ
nx release version
โฏ
nx release changelog
โฏ
nx release publish
reset
Clears cached Nx artifacts and metadata about the workspace and shuts down the Nx Daemon.
โฏ
nx reset
Display Information
show
Show information about the workspace (e.g., list of projects)
โฏ
nx show projects
โฏ
nx show project my-app
graph
Graph dependencies within workspace
โฏ
nx graph
list
Lists installed plugins, capabilities of installed plugins and other available plugins.
โฏ
nx list
โฏ
nx list my-plugin
report
Reports useful version numbers to copy into the Nx issue template
โฏ
nx report
daemon
Prints information about the Nx Daemon process or starts a daemon process
โฏ
nx daemon
Integrate with Nx Cloud
connect
Connect an Nx workspace to Nx Cloud
โฏ
nx connect
login
Login to Nx Cloud. This command is an alias for nx-cloud login
.
โฏ
nx login
logout
Logout from Nx Cloud. This command is an alias for nx-cloud logout
.
โฏ
nx logout
Create Commands
create-nx-workspace
Create a new Nx workspace
โฏ
npx create-nx-workspace
create-nx-plugin
Create a new Nx workspace with a preset designed for writing an Nx plugin
โฏ
npx create-nx-plugin