Skip to content

The @nx/node plugin provides various generators to help you create and configure node projects within your Nx workspace. Below is a complete reference for all available generators and their options.

application

Nx Application Options Schema.

Usage:

Terminal window
nx generate @nx/node:application [options]

Aliases: app

Arguments:

Terminal window
nx generate @nx/node:application <directory> [options]

Options

OptionTypeDescriptionDefault
--babelJestbooleanUse babel instead ts-jest.false
--bundlerstringBundler which is used to package the application"esbuild"
--dockerbooleanAdd a docker build target
--e2eTestRunnerstringTest runner to use for end-to-end tests"none"
--frameworkstringGenerate the node application using a framework"none"
--frontendProjectstringFrontend project that needs to access this application. This sets up proxy configuration.
--jsbooleanGenerate JavaScript files rather than TypeScript files.false
--linterstringThe tool to use for running lint checks."none"
--namestringThe name of the application.
--portnumberThe port which the server will be run on3000
--rootProjectbooleanCreate node application at the root of the workspacefalse
--setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
--skipDockerPluginbooleanSkip the @nx/docker plugin and use the legacy docker build target instead.false
--skipFormatbooleanSkip formatting filesfalse
--skipPackageJsonbooleanDo not add dependencies to package.json.false
--standaloneConfigbooleanSplit the project configuration into <projectRoot>/project.json rather than including it inside workspace.json.true
--swcJestbooleanUse @swc/jest instead ts-jest for faster test compilation.
--tagsstringAdd tags to the application (used for linting).
--unitTestRunnerstringTest runner to use for unit tests."none"
--useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

library

Create a Node Library for an Nx workspace.

Usage:

Terminal window
nx generate @nx/node:library [options]

Aliases: lib

Arguments:

Terminal window
nx generate @nx/node:library <directory> [options]

Options

OptionTypeDescriptionDefault
--babelJestbooleanUse babel instead of ts-jest.false
--buildablebooleanGenerate a buildable library.true
--compilerstringThe compiler used by the build and test targets."tsc"
--importPathstringThe library name used to import it, like @myorg/my-awesome-lib. Must be a valid npm name.
--jsbooleanGenerate JavaScript files rather than TypeScript files.false
--linterstringThe tool to use for running lint checks."none"
--namestringLibrary name
--publishablebooleanCreate a publishable library.
--rootDirstringSets the rootDir for TypeScript compilation. When not defined, it uses the project’s root property, or srcRootForCompilationRoot if it is defined.
--setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project. We do not do this by default for lint performance reasons.false
--simpleModuleNamebooleanKeep the module name simple.false
--skipFormatbooleanSkip formatting files.false
--skipTsConfigbooleanDo not update tsconfig.base.json for development experience.false
--standaloneConfigbooleanSplit the project configuration into <projectRoot>/project.json rather than including it inside workspace.json.true
--strictbooleanWhether to enable tsconfig strict mode or not.false
--tagsstringAdd tags to the library (used for linting).
--testEnvironmentstringThe test environment to use if unitTestRunner is set to jest."jsdom"
--unitTestRunnerstringTest runner to use for unit tests."none"
--useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

setup-docker

Nx Node Docker Options Schema.

Usage:

Terminal window
nx generate @nx/node:setup-docker [options]

Options

OptionTypeDescriptionDefault
--buildTargetNamestringThe name of the build target"build"
--outputPathstringThe output path for the node application
--projectstringThe name of the project
--skipDockerPluginbooleanSkip the @nx/docker plugin and use the legacy docker build target instead.false
--targetNamestringThe name of the target to create"docker:build"

Getting Help

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

Terminal window
nx generate @nx/node:<generator> --help