Skip to main content
Alias: nx g nx generate runs a generator to create, modify, or delete files in your workspace. Generators are provided by Nx plugins (e.g., @nx/react, @nx/js) and can also be defined locally in your workspace.

Arguments

string
required
The generator to run, in the format collection:generator (e.g., @nx/react:application) or just generator if the collection can be inferred.

Options

boolean
default:"false"
Preview the file changes that would be made without actually writing them to disk. Alias: -d. Also enabled by setting NX_DRY_RUN=true.
boolean
default:"true"
When false, disables interactive input prompts for generator options. All required options must be provided as flags. Also controlled by NX_INTERACTIVE=false.
boolean
Hides logs from file system operations (e.g., CREATE package.json). Cannot be used together with --verbose.
boolean
Prints additional information about the generation process, including stack traces on error. Cannot be used together with --quiet.

Listing available generators

Use nx list to discover generators from installed plugins:
To see the options for a specific generator, pass --help after the generator name:

Examples

Generator options vary by plugin and generator. Always check the generator’s schema with --help before running.

Workspace generators

You can define your own generators locally in tools/generators. Run them by their name without a collection prefix:
Or with the local plugin collection: