Building for Production

Build and Run

Example

npm ci
npm run build
NODE_ENV=production node dist/main.js

Example output

> [email protected] build
> nest build

[Nest] 1  - LOG [NestFactory] Starting Nest application...
[Nest] 1  - LOG [NestApplication] Nest application successfully started +38ms
  • nest build compiles TypeScript to dist/ (tsc or SWC with "builder": "swc" in nest-cli.json, which is much faster).
  • Run database migrations as a separate step before starting the new version (npx prisma migrate deploy or typeorm migration:run).
  • Call app.enableShutdownHooks() so the app closes DB connections and finishes requests on SIGTERM.