Skip to content

@nx/node - Generators

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.

For an overview of the plugin and setup instructions, see the @nx/node introduction.

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]
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"
--enableTypedLintingbooleanWhether to enable typed linting. For flat configs, this configures the recommended parserOptions.projectService and tsconfigRootDir. For legacy .eslintrc configs, this configures parserOptions.project. We do not enable this by default for lint performance reasons.false
--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
--keepExistingVersionsbooleanKeep existing dependencies versionstrue
--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
--setParserOptionsProjectbooleanDeprecated alias for enableTypedLinting.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
--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.

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]
OptionTypeDescriptionDefault
--babelJestbooleanUse babel instead of ts-jest.false
--buildablebooleanGenerate a buildable library.true
--compilerstringThe compiler used by the build and test targets."tsc"
--enableTypedLintingbooleanWhether to enable typed linting. For flat configs, this configures the recommended parserOptions.projectService and tsconfigRootDir. For legacy .eslintrc configs, this configures parserOptions.project. We do not enable this by default for lint performance reasons.false
--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.
--setParserOptionsProjectbooleanDeprecated alias for enableTypedLinting.false
--simpleModuleNamebooleanKeep the module name simple.false
--skipFormatbooleanSkip formatting files.false
--skipTsConfigbooleanDo not update tsconfig.base.json for development experience.false
--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.

Nx Node Docker Options Schema.

Usage:

Terminal window
nx generate @nx/node:setup-docker [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"

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

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