Skip to content

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.

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]
OptionTypeDescriptionDefault
--cistring [required]CI provider.
--useRunManybooleanUse ‘nx run-many’ instead of ‘nx affected’ in the generated CI workflow.false

Convert an Nx project to a monorepo.

Usage:

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

Migrates v1 config to v2 standalone configuration.

Usage:

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

Aliases: convert-to-nx-project

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

Convert Nx projects to use inferred targets.

Usage:

Terminal window
nx generate @nx/workspace:infer-targets [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 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]
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

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]
OptionTypeDescriptionDefault
--namestringPackage name.

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]
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

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]
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.

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

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