CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-nestjs--cli

Command-line interface tool for initializing, developing, and maintaining NestJS applications

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

development-server.mddocs/

Development Server

Start NestJS applications in development mode with hot reloading, debugging support, and comprehensive configuration options. The development server provides an efficient workflow for rapid application development and testing.

Capabilities

Start Command

Launches your NestJS application with development-focused features and extensive customization options.

# Start application
nest start [app] [options]

# Options:
-c, --config [path]                 # Path to nest-cli configuration file
-p, --path [path]                   # Path to tsconfig file
-w, --watch                        # Run in watch mode (live-reload)
-b, --builder [name]               # Builder to be used (tsc, webpack, swc)
--watchAssets                      # Watch non-ts (e.g., .graphql) files mode
-d, --debug [hostport]             # Run in debug mode (with --inspect flag)
--webpack                          # Use webpack for compilation (deprecated, use --builder)
--webpackPath [path]               # Path to webpack configuration
--type-check                       # Enable type checking (when SWC is used)
--tsc                             # Use typescript compiler for compilation
--sourceRoot [sourceRoot]          # Points at the root of the source code
--entryFile [entryFile]            # Path to the entry file
-e, --exec [binary]                # Binary to run (default: "node")
--preserveWatchOutput             # Use "preserveWatchOutput" option when using tsc watch mode
--shell                           # Spawn child processes within a shell (default: true)
--no-shell                        # Do not spawn child processes within a shell
--env-file [path]                 # Path to an env file (.env) to be loaded

Usage Examples:

# Basic development server
nest start

# Start with watch mode (hot reload)
nest start --watch

# Start specific app in monorepo
nest start api-gateway

# Start with debug mode
nest start --debug
nest start --debug 0.0.0.0:9229

# Start with asset watching
nest start --watch --watchAssets

# Start with specific builder
nest start --builder webpack
nest start --builder swc --type-check

# Start with environment file
nest start --env-file .env.development

# Start with custom entry point
nest start --entryFile src/main.ts

# Start with custom binary
nest start --exec "node --max-old-space-size=4096"

Development Features

Watch Mode

Automatically restart the application when files change:

# Enable hot reloading
nest start --watch

# Watch with asset monitoring
nest start --watch --watchAssets

Watched File Types:

  • TypeScript files (.ts)
  • JavaScript files (.js)
  • JSON configuration files
  • GraphQL schema files (with --watchAssets)
  • Protocol buffer definitions (with --watchAssets)

Debug Mode

Enable Node.js debugging with Inspector protocol:

# Debug on default port (9229)
nest start --debug

# Debug on specific host:port
nest start --debug 0.0.0.0:9229
nest start --debug localhost:9229

# Debug with watch mode
nest start --debug --watch

Debug Configuration:

  • Enables --inspect flag automatically
  • Supports Chrome DevTools
  • Compatible with VS Code debugger
  • Works with watch mode for continuous debugging

Environment Configuration

Load environment variables from files:

# Single environment file
nest start --env-file .env.development

# Multiple environment files
nest start --env-file .env --env-file .env.local

Build System Integration

TypeScript Compiler

# Use TypeScript compiler
nest start --builder tsc --watch

# With preserved watch output
nest start --builder tsc --watch --preserveWatchOutput

Webpack Development Server

# Use Webpack with HMR
nest start --builder webpack --watch

# Custom webpack configuration
nest start --builder webpack --webpackPath webpack.dev.js

SWC for Fast Compilation

# Use SWC for fast development builds
nest start --builder swc --watch

# SWC with type checking
nest start --builder swc --type-check --watch

Process Management

Shell Configuration

Control how child processes are spawned:

# Use shell (default)
nest start --shell

# No shell spawning
nest start --no-shell

Custom Binary Execution

Specify the runtime binary and options:

# Default Node.js
nest start --exec node

# Node with memory optimization
nest start --exec "node --max-old-space-size=4096"

# Node with experimental features
nest start --exec "node --experimental-modules"

Project Structure Support

Monorepo Applications

# Start specific application
nest start api-gateway
nest start user-service
nest start payment-service

# Start with project-specific config
nest start api-gateway --config apps/api-gateway/nest-cli.json

Custom Entry Points

# Custom entry file
nest start --entryFile src/main.ts
nest start --entryFile apps/api/src/main.ts

# Custom source root
nest start --sourceRoot src
nest start --sourceRoot apps/api/src

Configuration Files

nest-cli.json Development Settings

{
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "builder": "webpack",
    "typeCheck": true,
    "assets": ["**/*.proto", "**/*.graphql"],
    "watchAssets": true
  },
  "generateOptions": {
    "spec": false
  }
}

Environment File Loading

Supported environment file formats:

# .env files
.env
.env.local
.env.development
.env.development.local

Environment file example:

NODE_ENV=development
PORT=3000
DATABASE_URL=postgresql://localhost:5432/nestjs_dev
LOG_LEVEL=debug

Performance Optimization

Fast Development Builds

# Fastest startup with SWC
nest start --builder swc --watch

# Balance speed and features with Webpack
nest start --builder webpack --watch

# Full type safety with TypeScript
nest start --builder tsc --watch --preserveWatchOutput

Memory Management

# Increase Node.js memory limit
nest start --exec "node --max-old-space-size=8192"

# Enable garbage collection optimization
nest start --exec "node --optimize-for-size"

Development Workflow Integration

Common Development Commands

# Standard development workflow
nest start --watch --debug

# Full-featured development with assets
nest start --watch --watchAssets --debug --env-file .env.development

# Fast iteration development
nest start --builder swc --watch --type-check

IDE Integration

The development server works seamlessly with:

  • VS Code with Node.js debugging
  • WebStorm with built-in Node.js support
  • Chrome DevTools for debugging
  • Any editor with Language Server Protocol support

Error Handling

Invalid Builder Options

# Invalid builder name
nest start --builder invalid
# Error: Invalid builder option: invalid. Available builders: tsc, webpack, swc

Process Exit Handling

The CLI properly handles process termination and cleanup:

  • Graceful shutdown on SIGTERM/SIGINT
  • Child process cleanup
  • File watcher cleanup
  • Port release

Error Recovery

In watch mode, the CLI recovers from compilation errors:

  • Continues watching after TypeScript errors
  • Restarts on successful compilation
  • Preserves debug connections when possible

docs

application-building.md

code-generation.md

development-server.md

index.md

library-integration.md

project-creation.md

project-information.md

tile.json