CLI command reference
nest new#
Creates a new (standard mode) Nest project.
$ nest new <name> [options]
$ nest n <name> [options]
Description
Creates and initializes a new Nest project. Prompts for the module system (ESM or CommonJS) and the package manager.
Hint Choosing ESM scaffolds an ESM-first project using Vitest for testing; choosing CommonJS scaffolds the traditional layout using Jest. Both variants use oxlint for linting.
- Creates a folder with the given
<name> - Populates the folder with configuration files
- Creates sub-folders for source code (
/src) and end-to-end tests (/test) - Populates the sub-folders with default files for app components and tests
Arguments
| Argument | Description |
|---|---|
<name> | The name of the new project |
Options
| Option | Description |
|---|---|
--directory [directory] | Specify the destination directory. |
--dry-run | Reports changes that would be made, but does not change the filesystem. Alias: -d |
--skip-git | Skip git repository initialization. Alias: -g |
--skip-install | Skip package installation. Alias: -s |
--skip-tests | Do not generate testing files for the new project. Alias: -t |
--package-manager [package-manager] | Specify package manager. Use npm, yarn, pnpm, or bun. Package manager must be installed globally.Alias: -p |
--language [language] | Specify programming language (TS or JS).Alias: -l |
--collection [collectionName] | Specify schematics collection. Use package name of installed npm package containing schematic. Alias: -c |
--strict | Start the project with the following TypeScript compiler flags enabled: strictNullChecks, noImplicitAny, strictBindCallApply, forceConsistentCasingInFileNames, noFallthroughCasesInSwitch |
--format | Format generated files using Prettier. |
--observe / --no-observe | Auto-configure observability with @nestjs/observe, or skip the prompt entirely. |
nest generate#
Generates and/or modifies files based on a schematic
$ nest generate <schematic> <name> [options]
$ nest g <schematic> <name> [options]
Arguments
| Argument | Description |
|---|---|
<schematic> | The schematic or collection:schematic to generate. See the table below for the available schematics. |
<name> | The name of the generated component. |
Schematics
| Name | Alias | Description |
|---|---|---|
app | Generate a new application within a monorepo (converting to monorepo if it's a standard structure). | |
library | lib | Generate a new library within a monorepo (converting to monorepo if it's a standard structure). |
class | cl | Generate a new class. |
controller | co | Generate a controller declaration. |
decorator | d | Generate a custom decorator. As of v12, the generated decorator uses the preferred Reflector.createDecorator() form. |
filter | f | Generate a filter declaration. |
gateway | ga | Generate a gateway declaration. |
guard | gu | Generate a guard declaration. |
interface | itf | Generate an interface. |
interceptor | itc | Generate an interceptor declaration. |
middleware | mi | Generate a middleware declaration. |
module | mo | Generate a module declaration. |
pipe | pi | Generate a pipe declaration. |
provider | pr | Generate a provider declaration. |
resolver | r | Generate a resolver declaration. |
resource | res | Generate a new CRUD resource. See the CRUD (resource) generator for more details. (TS only) |
service | s | Generate a service declaration. |
Options
| Option | Description |
|---|---|
--dry-run | Reports changes that would be made, but does not change the filesystem. Alias: -d |
--project [project] | Project that element should be added to. Alias: -p |
--flat | Do not generate a folder for the element. |
--no-flat | Generate a folder for the element. |
--collection [collectionName] | Specify schematics collection. Use package name of installed npm package containing schematic. Alias: -c |
--spec | Enforce spec files generation (default) |
--no-spec | Disable spec files generation |
--spec-file-suffix [suffix] | Use a custom suffix for spec files. |
--skip-import | Skip importing the generated element into its closest module. |
--format | Format generated files using Prettier. |
nest build#
Compiles an application or workspace into an output folder.
Also, the build command is responsible for:
- mapping paths (if using path aliases) via
tsconfig-paths - annotating DTOs with OpenAPI decorators (if
@nestjs/swaggerCLI plugin is enabled) - annotating DTOs with GraphQL decorators (if
@nestjs/graphqlCLI plugin is enabled)
$ nest build <name> [options]
Arguments
| Argument | Description |
|---|---|
<name> | The name of the project to build. |
Options
| Option | Description |
|---|---|
--path [path] | Path to tsconfig file. Alias -p |
--config [path] | Path to nest-cli configuration file. Alias -c |
--watch | Run in watch mode (live-reload). If you're using tsc for compilation, you can type rs to restart the application (when manualRestart option is set to true). Alias -w |
--builder [name] | Specify the builder to use for compilation (tsc, swc, or rspack). Alias -b |
--webpack | Deprecated legacy flag for webpack-based compilation. Prefer --builder rspack or another explicit builder. |
--webpackPath | Deprecated legacy path to a webpack configuration file. Prefer the configuration supported by your selected builder. |
--rspackPath [path] | Path to a Rspack configuration file. |
--tsc | Force use tsc for compilation. |
--watchAssets | Watch non-TS files (assets like .graphql etc.). See Assets for more details. |
--type-check | Enable type checking (when SWC is used). |
--no-type-check | Disable type checking (when SWC is used). |
--emit-declarations | Emit declaration files (.d.ts) when using the SWC builder. |
--all | Build all projects in a monorepo. |
--parallel [concurrency] | Build projects in parallel (used with --all). Pass a positive integer to limit concurrency, or omit the value for unlimited. |
--silent | Suppress informational compiler logs. |
--preserveWatchOutput | Keep outdated console output in watch mode instead of clearing the screen. (tsc watch mode only) |
nest start#
Compiles and runs an application (or default project in a workspace).
$ nest start <name> [options]
Arguments
| Argument | Description |
|---|---|
<name> | The name of the project to run. |
Options
| Option | Description |
|---|---|
--path [path] | Path to tsconfig file. Alias -p |
--config [path] | Path to nest-cli configuration file. Alias -c |
--watch | Run in watch mode (live-reload) Alias -w |
--builder [name] | Specify the builder to use for compilation (tsc, swc, or rspack). Alias -b |
--preserveWatchOutput | Keep outdated console output in watch mode instead of clearing the screen. (tsc watch mode only) |
--watchAssets | Run in watch mode (live-reload), watching non-TS files (assets). See Assets for more details. |
--debug [hostport] | Run in debug mode (with --inspect flag) Alias -d |
--webpack | Deprecated legacy flag for webpack-based compilation. Prefer --builder rspack or another explicit builder. |
--webpackPath | Deprecated legacy path to a webpack configuration file. Prefer the configuration supported by your selected builder. |
--rspackPath [path] | Path to a Rspack configuration file. |
--tsc | Force use tsc for compilation. |
--type-check | Enable type checking (when SWC is used). |
--no-type-check | Disable type checking (when SWC is used). |
--emit-declarations | Emit declaration files (.d.ts) when using the SWC builder. |
--silent | Suppress informational compiler logs. |
--exec [binary] | Binary to run (default: node). Alias -e |
--no-shell | Do not spawn child processes within a shell (see node's child_process.spawn() method docs). |
--env-file | Loads environment variables from a file relative to the current directory, making them available to applications on process.env. |
-- [key=value] | Command-line arguments that can be referenced with process.argv. |
nest add#
Imports a library that has been packaged as a nest library, running its install schematic.
$ nest add <name> [options]
Arguments
| Argument | Description |
|---|---|
<name> | The name of the library to import. |
Options
| Option | Description |
|---|---|
--dry-run | Reports changes that would be made, but does not change the filesystem. Alias: -d |
--skip-install | Skip package installation. Alias: -s |
--project [project] | Project that the library should be added to. Alias: -p |
nest upgrade#
Upgrades an existing project to the latest NestJS major version.
$ nest upgrade [options]
$ nest update [options]
Description
Run from the root of a NestJS v11 project, nest upgrade updates your dependencies to v12 and applies the mechanical parts of the migration for you:
- Bumps every recognized
@nestjs/*package to its v12-compatible major (@nestjs/graphql,@nestjs/apollo, and@nestjs/mercuriusgo to v14), and reports any other@nestjs/*package it does not know about so you can review it yourself - Migrates
nest-cli.jsonoff the deprecatedwebpack/webpackConfigPathoptions and onto--builder rspack, updating matchingpackage.jsonscripts - Renames the GraphQL
playgroundoption tographiql, switches subscriptions fromsubscriptions-transport-wstographql-ws, and swaps the packages accordingly - Replaces the legacy
natspackage with@nats-io/transport-node/@nats-io/nats-coreand rewritesnatsimports - Moves library-specific
@nestjs/configsettings undervalidationOptions.libraryOptionsand bumps Joi to v18 (the first release implementing Standard Schema) - Bumps Jest (and
@types/jest/ts-jest) where present, and warns when your Node.js version is too old torequire()the ESM-only v12 packages - Optionally installs and wires up
@nestjs/observe- it prompts, unless you pass--observeor--no-observe - Scans your sources and prints notes about behavior that changed but cannot be migrated automatically, such as lifecycle hook ordering, refined pipe signatures, and structured logging params
The command finishes by installing the updated dependencies (unless --skip-install is passed) and printing a report of everything it changed, warned about, and left for you.
Warningnest upgradeonly bumps the local@nestjs/clidependency. Update a globally installed CLI yourself withnpm i -g @nestjs/cli@latest- and do it before running the upgrade, since the command itself ships with the CLI.
Hint The schematic deliberately does not migrate your project to ESM, Vitest, or oxlint. Those are the defaults for newly generated v12 projects, but existing projects can adopt them on their own schedule. See the Migration guide for the full picture.
Options
| Option | Description |
|---|---|
--dry-run | Reports changes that would be made, but does not change the filesystem. Alias: -d |
--skip-install | Skip package installation. Alias: -s |
--observe / --no-observe | Set up @nestjs/observe, or skip the setup entirely. Omit both to be prompted. |
--tag [tag] | Use an npm dist-tag (for example next) instead of the default version ranges.Alias: -t |
--collection [collectionName] | Specify schematics collection. Use package name of installed npm package containing schematic. Alias: -c |
nest deploy#
Deploys your application to the cloud, powered by Mau.
$ nest deploy [mau-options]
Description
nest deploy is a thin wrapper around the Mau CLI. It locates the Mau binary and forwards every argument you pass straight through to mau deploy, so any option Mau supports works here unchanged.
If Mau is not installed in your project, the command offers to add @nestjs/mau as a dev dependency and then continues. In a non-interactive environment (for example CI) the command fails instead of prompting, so install it explicitly first:
$ npm install --save-dev @nestjs/mau
Because Mau owns the terminal once it starts, its output and any prompts it shows are passed through to you directly. See the Deployment chapter for what Mau does and how to configure it.
nest info#
Displays information about installed nest packages and other helpful system info. For example:
$ nest info
_ _ _ ___ _____ _____ _ _____
| \ | | | | |_ |/ ___|/ __ \| | |_ _|
| \| | ___ ___ | |_ | |\ `--. | / \/| | | |
| . ` | / _ \/ __|| __| | | `--. \| | | | | |
| |\ || __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/ \____/\_____/\___/
[System Information]
OS Version : macOS High Sierra
NodeJS Version : v20.18.0
[Nest Information]
microservices version : 10.0.0
websockets version : 10.0.0
testing version : 10.0.0
common version : 10.0.0
core version : 10.0.0

