The @nx/js:node executor runs the output of a build target. For example, an application uses esbuild (@nx/esbuild:esbuild) to output the bundle to dist/my-app folder, which can then be executed by @nx/js:node.

project.json:

"my-app": { "targets": { "serve": { "executor": "@nx/js:node", "options": { "buildTarget": "my-app:build" } }, "build": { "executor": "@nx/esbuild:esbuild", "options": { "main": "my-app/src/main.ts", "output": ["dist/my-app"], //... } }, } }
Nx 15 and lower use @nrwl/ instead of @nx/
npx nx serve my-app

Examples

Using runtimeArgs, you can pass arguments to the underlying node command. For example, if you want to set --no-warnings to silence all Node warnings, then add the following to the project.json file.

"my-app": { "targets": { "serve": { "executor": "@nx/js:node", "options": { "runtimeArgs": ["--no-warnings"], //... }, }, } }
Nx 15 and lower use @nrwl/ instead of @nx/

Options

buildTarget

Required
string

The target to run to build you the app.

args

Array<string>
Default: []

Extra args when starting the app.

debounce

number
Default: 500

Delay in milliseconds to wait before restarting. Useful to batch multiple file changes events together. Set to zero (0) to disable.

host

string
Default: localhost

The host to inspect the process on.

inspect

oneOf [string, boolean]
Default: inspect

Ensures the app is starting with debugging.

port

number
Default: 9229

The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes.

runtimeArgs

Array<string>
Default: []

Extra args passed to the node process.

watch

boolean
Default: true

Enable re-building when files change.

buildTargetOptions

object: object
Default: {}

Additional options to pass into the build target.

runBuildTargetDependencies

boolean
Default: false

Whether to run dependencies before running the build. Set this to true if the project does not build libraries from source (e.g. 'buildLibsFromSource: false').

waitUntilTargets

Array<string>
Default: []

The targets to run before starting the node app.