NestJS 11 cheatsheet

NestJS 11: CLI

6 common NestJS 11 tasks.

Install the Nest CLI

Install the command-line tool globally.

npm install -g @nestjs/cli

Create a project

Scaffold a new application.

nest new my-api

Run in watch mode

Start the app and restart on file changes.

npm run start:dev

Generate a full resource

Create a module, controller, service, DTOs and entity for a REST resource.

nest generate resource users

Generate individual parts

Create a module, controller, service, guard, pipe or interceptor.

nest g module orders
nest g controller orders
nest g service orders
nest g guard auth

Build for production

Compile to JavaScript in dist, then run it.

npm run build && node dist/main

Was this page helpful?