# Deployment — NestJS

Source: https://www.geekswithgeeks.com/en/nestjs/nestjs-deployment

> Deploy NestJS apps to production—build, optimize, and run.

## Build for production

Compile TypeScript to JavaScript; tree-shake unused code.

```bash
npm run build
ls dist/  # compiled JS output
```

## Run in production

Point `NODE_ENV=production` to your dist/ folder; optionally use a process manager like PM2.

```bash
NODE_ENV=production node dist/main.js

# or with PM2
pm2 start dist/main.js --name "nestjs-app"
```

## Health check endpoint

Add a `/health` or `/ping` endpoint for load balancers and orchestrators to poll.
