src/env.ts (dotenv.config()). The .env file must live in the server working directory.
First-time setup
Routine deploy
Verification
--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:./env at startup, so the standard start command above is sufficient when cwd is correct.
Zerodha auto-login deploy example
Environment is loaded viasrc/env.ts before other modules. PM2 must use the server directory as working directory.
node -r dotenv/config dist/src/app.js with cwd set to the server folder.