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:

1"my-app": { 2 "targets": { 3 "serve": { 4 "executor": "@nx/js:node", 5 "options": { 6 "buildTarget": "my-app:build" 7 } 8 }, 9 "build": { 10 "executor": "@nx/esbuild:esbuild", 11 "options": { 12 "main": "my-app/src/main.ts", 13 "output": ["dist/my-app"], 14 //... 15 } 16 }, 17 } 18} 19
1npx nx serve my-app 2

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.

1"my-app": { 2 "targets": { 3 "serve": { 4 "executor": "@nx/js:node", 5 "options": { 6 "runtimeArgs": ["--no-warnings"], 7 //... 8 }, 9 }, 10 } 11} 12

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. Listed in the form <project>:<target>. The main target will run once all listed targets have output something to the console.