About dotenv
dotenv is a small module with one focused job: load environment variables from a .env file into process.env.
How it works
Create a .env file in your project root, then call config() early in your application.
# .env
HELLO="World"
OPENAI_API_KEY="your-api-key-goes-here"
require('dotenv').config()
console.log(`Hello ${process.env.HELLO}`)
Common options
path
Load a custom file path instead of the default .env.
encoding
Use latin1 or another encoding when your file is not UTF-8.
override
Replace existing environment variables instead of skipping them.
debug
Log why a key or value was skipped, helping you troubleshoot fast.
Who uses it
dotenv is used by thousands of Node.js projects, from small scripts to production services. It is often paired with frameworks, CI pipelines, and deployment tooling.