Nx plugins usually infer tasks that run a tool's command-line interface directly. When no plugin can infer a task, configure the command or use an executor for Nx-specific behavior.
Run a terminal command
Section titled “Run a terminal command”Add a command when a target needs to run a shell command. Nx normalizes this shorthand to the nx:run-commands executor.
{ "name": "mylib", "nx": { "targets": { "check-licenses": { "command": "license-checker --summary", }, }, },}For multiple commands, environment variables, and working-directory options, see the run-commands executor.
Run an executor
Section titled “Run an executor”An executor is an implementation provided by an Nx plugin. Executors are useful when a task needs behavior that a command alone doesn't provide. Configure one with an executor value in the form <package-name>:<executor-name>.
For example, the @nx/js:node executor coordinates a build target with a running Node.js process. It rebuilds and restarts the process as source files change.
{ "name": "api", "nx": { "targets": { "serve": { "executor": "@nx/js:node", "continuous": true, "dependsOn": ["build"], "options": { "buildTarget": "api:build", }, }, }, },}This target contains the following fields:
executoridentifies the plugin package and executor implementation.optionsprovides default values defined by that executor's schema.continuoustells Nx that the task remains running.
Run an executor-backed target in the same way as any other target:
nx serve apiBrowse available executors in the plugin registry.
Use configurations
Section titled “Use configurations”The configurations property defines named option overrides. Nx merges the selected configuration into options, then applies command-line arguments.
{ "name": "api", "nx": { "targets": { "serve": { "executor": "@nx/js:node", "continuous": true, "dependsOn": ["build"], "options": { "buildTarget": "api:build", }, "configurations": { "development": { "buildTarget": "api:build:development", }, "production": { "buildTarget": "api:build:production", }, }, }, }, },}Select the configuration with either command form:
nx serve api --configuration=productionnx run api:serve:productionSet defaultConfiguration on the target when one named configuration should apply without the --configuration option. Explicitly selecting another configuration overrides that default.
Build an executor
Section titled “Build an executor”Create a local executor when your workspace needs reusable task behavior that a command or existing plugin doesn't provide. For the implementation and schema format, see create a local executor.