Configuration with dotenv
Keep settings in .env and load them with dotenv or node --env-file. Never commit secrets.
Example
// .env: PORT=3000
// node --env-file=.env app.js
console.log("PORT:", process.env.PORT ?? "not set");Result
PORT: not set
Exercise
Env file flag.
node ---file=.env
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.