What are environment variables and why use them?

Node.js basics · Freshers

Model answer

They are values set outside the code, read with process.env.NAME. Use them for secrets and settings that change between machines: database URLs, API keys, the port. They keep secrets out of Git. A .env file with the dotenv package (or node --env-file) is a common way to load them locally, and .env must never be committed.

Learn this topic

What Is Node.js? Install It and Run Your First Script in the course Node.js and Express: Build a Back End API from Scratch.

Sign in to add your own answer.

More questions