Environment variables are loaded via src/env.ts (dotenv.config()). The .env file must live in the server working directory.

First-time setup

Routine deploy

Verification

Confirm working directory and env:
Critical: PM2 --cwd must point to the folder containing .env. If env vars are missing, the process likely started from the wrong directory.

Alternative PM2 start

If dotenv does not load as expected:
The app imports ./env at startup, so the standard start command above is sufficient when cwd is correct.

Zerodha auto-login deploy example

Environment is loaded via src/env.ts before other modules. PM2 must use the server directory as working directory.
Verify PM2 cwd and env:
Alternative PM2 start (optional): node -r dotenv/config dist/src/app.js with cwd set to the server folder.