@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.
application
Section titled “application”Nx Application Options Schema.
Usage:
nx generate @nx/node:application [options]Aliases: app
Arguments:
nx generate @nx/node:application <directory> [options]Options
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--babelJest | boolean | Use babel instead ts-jest. | false |
--bundler | string | Bundler which is used to package the application | "esbuild" |
--docker | boolean | Add a docker build target | |
--e2eTestRunner | string | Test runner to use for end-to-end tests | "none" |
--enableTypedLinting | boolean | Whether 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 |
--framework | string | Generate the node application using a framework | "none" |
--frontendProject | string | Frontend project that needs to access this application. This sets up proxy configuration. | |
--js | boolean | Generate JavaScript files rather than TypeScript files. | false |
--keepExistingVersions | boolean | Keep existing dependencies versions | true |
--linter | string | The tool to use for running lint checks. | "none" |
--name | string | The name of the application. | |
--port | number | The port which the server will be run on | 3000 |
--rootProject | boolean | Create node application at the root of the workspace | false |
--setParserOptionsProject | boolean | Deprecated alias for enableTypedLinting. | false |
--skipDockerPlugin | boolean | Skip the @nx/docker plugin and use the legacy docker build target instead. | false |
--skipFormat | boolean | Skip formatting files | false |
--skipPackageJson | boolean | Do not add dependencies to package.json. | false |
--swcJest | boolean | Use @swc/jest instead ts-jest for faster test compilation. | |
--tags | string | Add tags to the application (used for linting). | |
--unitTestRunner | string | Test runner to use for unit tests. | "none" |
--useProjectJson | boolean | Use a project.json configuration file instead of inlining the Nx configuration in the package.json file. |
library
Section titled “library”Create a Node Library for an Nx workspace.
Usage:
nx generate @nx/node:library [options]Aliases: lib
Arguments:
nx generate @nx/node:library <directory> [options]Options
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--babelJest | boolean | Use babel instead of ts-jest. | false |
--buildable | boolean | Generate a buildable library. | true |
--compiler | string | The compiler used by the build and test targets. | "tsc" |
--enableTypedLinting | boolean | Whether 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 |
--importPath | string | The library name used to import it, like @myorg/my-awesome-lib. Must be a valid npm name. | |
--js | boolean | Generate JavaScript files rather than TypeScript files. | false |
--linter | string | The tool to use for running lint checks. | "none" |
--name | string | Library name | |
--publishable | boolean | Create a publishable library. | |
--rootDir | string | Sets the rootDir for TypeScript compilation. When not defined, it uses the project’s root property, or srcRootForCompilationRoot if it is defined. | |
--setParserOptionsProject | boolean | Deprecated alias for enableTypedLinting. | false |
--simpleModuleName | boolean | Keep the module name simple. | false |
--skipFormat | boolean | Skip formatting files. | false |
--skipTsConfig | boolean | Do not update tsconfig.base.json for development experience. | false |
--strict | boolean | Whether to enable tsconfig strict mode or not. | false |
--tags | string | Add tags to the library (used for linting). | |
--testEnvironment | string | The test environment to use if unitTestRunner is set to jest. | "jsdom" |
--unitTestRunner | string | Test runner to use for unit tests. | "none" |
--useProjectJson | boolean | Use a project.json configuration file instead of inlining the Nx configuration in the package.json file. |
setup-docker
Section titled “setup-docker”Nx Node Docker Options Schema.
Usage:
nx generate @nx/node:setup-docker [options]Options
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--buildTargetName | string | The name of the build target | "build" |
--outputPath | string | The output path for the node application | |
--project | string | The name of the project | |
--skipDockerPlugin | boolean | Skip the @nx/docker plugin and use the legacy docker build target instead. | false |
--targetName | string | The name of the target to create | "docker:build" |
Getting Help
Section titled “Getting Help”You can get help for any generator by adding the --help flag:
nx generate @nx/node:<generator> --help