NestJS Logo

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 package manager.

  • 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
ArgumentDescription
<name>The name of the new project
Options
OptionDescription
--dry-runReports changes that would be made, but does not change the filesystem.
Alias: -d
--skip-gitSkip git repository initialization.
Alias: -g
--skip-installSkip package installation.
Alias: -s
--package-manager [package-manager]Specify package manager. Use npm or yarn. 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

nest generate#

Generates and/or modifies files based on a schematic


$ nest generate <schematic> <name> [options]
$ nest g <schematic> <name> [options]
Arguments
ArgumentDescription
<schematic>The schematic or collection:schematic to generate. See the table below for the available schematics.
<name>The name of the generated component.
Schematics
NameAliasDescription
appGenerate a new application within a monorepo (converting to monorepo if it's a standard structure).
librarylibGenerate a new library within a monorepo (converting to monorepo if it's a standard structure).
classclGenerate a new class.
controllercoGenerate a controller declaration.
decoratordGenerate a custom decorator.
filterfGenerate a filter declaration.
gatewaygaGenerate a gateway declaration.
guardguGenerate a guard declaration.
interfaceGenerate an interface.
interceptorinGenerate an interceptor declaration.
middlewaremiGenerate a middleware declaration.
modulemoGenerate a module declaration.
pipepiGenerate a pipe declaration.
providerprGenerate a provider declaration.
resolverrGenerate a resolver declaration.
resourceresGenerate a new CRUD resource. See the CRUD (resource) generator for more details.
servicesGenerate a service declaration.
Options
OptionDescription
--dry-runReports changes that would be made, but does not change the filesystem.
Alias: -d
--project [project]Project that element should be added to.
Alias: -p
--flatDo not generate a folder for the element.
--collection [collectionName]Specify schematics collection. Use package name of installed npm package containing schematic.
Alias: -c
--specEnforce spec files generation (default)
--no-specDisable spec files generation

nest build#

Compiles an application or workspace into an output folder.


$ nest build <name> [options]
Arguments
ArgumentDescription
<name>The name of the project to build.
Options
OptionDescription
--path [path]Path to tsconfig file.
Alias -p
--config [path]Path to nest-cli configuration file.
Alias -c
--watchRun in watch mode (live-reload)
Alias -w
--webpackUse webpack for compilation.
--webpackPathPath to webpack configuration.
--tscForce use tsc for compilation.

nest start#

Compiles and runs an application (or default project in a workspace).


$ nest start <name> [options]
Arguments
ArgumentDescription
<name>The name of the project to run.
Options
OptionDescription
--path [path]Path to tsconfig file.
Alias -p
--config [path]Path to nest-cli configuration file.
Alias -c
--watchRun in watch mode (live-reload)
Alias -w
--preserveWatchOutputKeep outdated console output in watch mode instead of clearing the screen. (tsc watch mode only)
--watchAssetsRun 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
--webpackUse webpack for compilation.
--webpackPathPath to webpack configuration.
--tscForce use tsc for compilation.
--exec [binary]Binary to run (default: node).
Alias -e

nest add#

Imports a library that has been packaged as a nest library, running its install schematic.


$ nest add <name> [options]
Arguments
ArgumentDescription
<name>The name of the library to import.

nest update#

Updates @nestjs dependencies in the package.json"dependencies" list to their @latest version.

Options
OptionDescription
--forceDo upgrade instead of update
Alias -f
--tagUpdate to tagged version (use @latest, @<tag>, etc)
Alias -t

nest info#

Displays information about installed nest packages and other helpful system info. For example:


 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/

[System Information]
OS Version : macOS High Sierra
NodeJS Version : v8.9.0
YARN Version : 1.5.1
[Nest Information]
microservices version : 6.0.0
websockets version : 6.0.0
testing version : 6.0.0
common version : 6.0.0
core version : 6.0.0

Support us

Nest is an MIT-licensed open source project. It can grow thanks to the support by these awesome people. If you'd like to join them, please read more here.

Principal Sponsors

Sanofi LogoTrilon Logo

Sponsors / Partners

Become a sponsor