CLI command reference

nest new

Creates a new (standard mode) Nest project.

  1. $ nest new <name> [options]
  2. $ 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
Argument Description
<name> The name of the new project
Options
Option Description
--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
--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

  1. $ nest generate <schematic> <name> [options]
  2. $ 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
application 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.
filter f Generate a filter declaration.
gateway ga Generate a gateway declaration.
guard gu Generate a guard declaration.
interface Generate an interface.
interceptor in 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.
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.
--collection [collectionName] Specify schematics collection. Use package name of installed npm package containing schematic. Alias: -c

| --no-spec | Disable spec files generation |

nest build

Compiles an application or workspace into an output folder.

  1. $ 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
--watch Run in watch mode (live-reload) Alias -w
--webpack Use webpack for compilation.
--webpackPath Path to webpack configuration.

nest start

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

  1. $ 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
--watch Run in watch mode (live-reload) Alias -w
--debug [hostport] Run in debug mode (with —inspect flag) Alias -d
--webpack Use webpack for compilation.
--webpackPath Path to webpack configuration.

nest add

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

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

nest update

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

Options
Option Description
--force Do upgrade instead of update Alias -f
--tag Update to tagged version (use @latest, @<tag>, etc) Alias -wt

nest info

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

  1. _ _ _ ___ _____ _____ _ _____
  2. | \ | | | | |_ |/ ___|/ __ \| | |_ _|
  3. | \| | ___ ___ | |_ | |\ `--. | / \/| | | |
  4. | . ` | / _ \/ __|| __| | | `--. \| | | | | |
  5. | |\ || __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
  6. \_| \_/ \___||___/ \__|\____/ \____/ \____/\_____/\___/
  7. [System Information]
  8. OS Version : macOS High Sierra
  9. NodeJS Version : v8.9.0
  10. YARN Version : 1.5.1
  11. [Nest Information]
  12. microservices version : 6.0.0
  13. websockets version : 6.0.0
  14. testing version : 6.0.0
  15. common version : 6.0.0
  16. core version : 6.0.0