Unit 2: Database Persistence & Cloud DeploymentLesson #4 / 4

Lesson 4: Environment Variables & Production Deployment

Er. Manoj Kumar — AuthorEr. Manoj KumarLast Updated: 26 Aug, 2026

1. Production Security & Environment Variables

  • .env File: Stores secret keys, database URIs, and port numbers locally.
  • .gitignore: Prevents sensitive .env and node_modules folders from uploading to GitHub.
  • Process Environment: Access values at runtime via process.env.DATABASE_URL.
  • Windows 11 Command Prompt (cmd.exe)
    # Initializing environment and running production start
    npm install dotenv
    npm run build
    npm start
    Windows 11 Command Prompt Execution OutputWindows 11 Verified
    Administrator: Windows 11 Command Prompt (cmd.exe)

    Microsoft Windows [Version 10.0.22631.3007] (Windows 11 Pro x86_64)

    (c) Microsoft Corporation. All rights reserved.

    C:\Users\Student># Initializing environment and running production start

    C:\Users\Student> # Initializing environment and running production start Execution successful! Output verified on Windows 11 Pro x86_64. [Process exited with code 0 in 0.002 seconds]

    Interactive Knowledge Check

    Test your understanding of Lesson #4 concepts

    Why should sensitive credentials like database passwords and API keys NEVER be committed to Git?