Skip to content

@nx/workspace Generators

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

ci-workflow

Generate a CI workflow.

Usage:

Terminal window
nx generate @nx/workspace:ci-workflow [options]

Arguments:

Terminal window
nx generate @nx/workspace:ci-workflow <name> [options]

Options

OptionTypeDescriptionDefault
cistring [required]CI provider.
useRunManybooleanUse ‘nx run-many’ instead of ‘nx affected’ in the generated CI workflow.false

convert-to-monorepo

Convert an Nx project to a monorepo.

Usage:

Terminal window
nx generate @nx/workspace:convert-to-monorepo [options]

fix-configuration

Migrates v1 config to v2 standalone configuration.

Usage:

Terminal window
nx generate @nx/workspace:fix-configuration [options]

Aliases: convert-to-nx-project

Options

OptionTypeDescriptionDefault
allbooleanConvert all projects
projectstringConvert a single project
reformatbooleanJust reformats the configuration
skipFormatbooleanSkip formatting filesfalse

infer-targets

Convert Nx projects to use inferred targets.

Usage:

Terminal window
nx generate @nx/workspace:infer-targets [options]

Options

OptionTypeDescriptionDefault
pluginsarrayThe plugins used to infer targets. For example @nx/eslint or @nx/jest
projectstringThe project to convert to use inferred targets.
skipFormatbooleanWhether to format files.false

move

Move a project to another folder in the workspace.

Usage:

Terminal window
nx generate @nx/workspace:move [options]

Aliases: mv

Arguments:

Terminal window
nx generate @nx/workspace:move <destination> [options]

Options

OptionTypeDescriptionDefault
projectNamestring [required]The name of the project to move.
importPathstringThe new import path to use in the tsconfig.base.json.
newProjectNamestringThe new name of the project after the move.
skipFormatbooleanSkip formatting files.false
updateImportPathbooleanShould the generator update the import path to reflect the new location?true

npm-package

Add a minimal npm package.

Usage:

Terminal window
nx generate @nx/workspace:npm-package [options]

Arguments:

Terminal window
nx generate @nx/workspace:npm-package <directory> [options]

Options

OptionTypeDescriptionDefault
namestringPackage name.

remove

Remove a project from the workspace.

Usage:

Terminal window
nx generate @nx/workspace:remove [options]

Aliases: rm

Arguments:

Terminal window
nx generate @nx/workspace:remove <projectName> [options]

Options

OptionTypeDescriptionDefault
forceRemovebooleanWhen true, forces removal even if the project is still in use.false
importPathstringThe library name used at creation time
skipFormatbooleanSkip formatting files.false

run-commands

Create a custom target to run any command.

Usage:

Terminal window
nx generate @nx/workspace:run-commands [options]

Aliases: run-command, target

Arguments:

Terminal window
nx generate @nx/workspace:run-commands <name> [options]

Options

OptionTypeDescriptionDefault
commandstring [required]Command to run.
projectstring [required]Project name.
cwdstringCurrent working directory of the command.
envFilestringEnv files to be loaded before executing the commands.
outputsstringAllows you to specify where the build artifacts are stored. This allows Nx Cloud to pick them up correctly, in the case that the build artifacts are placed somewhere other than the top level dist folder.
## Getting Help
You can get help for any generator by adding the `--help` flag:
```bash
nx generate @nx/workspace:<generator> --help
```