Member-only story

Documenting .env files for nodejs Projects

Sahu
2 min readJun 7, 2021

--

The original post is published on my Blog at mrsauravsahu

Note: There’s a video version available where I actually build this project and deploy it to npmjs

Documentation of any sort looks like an overhead at the time, but pays off really well for projects that need to be maintained for a long time, when teams change, when onboarding new members, and a whole lot others.

For nodejs projects, application configuration is usually read from process.env which in turn, come from a place like ENVIRONMENT variables or a configuration file like .env. During development, this package, dotenv is a great tool to set your environment variables.

Documentation is Key

For large projects with even larger teams, code-base changes constantly and so does the configuration. So documentation is key to keep anyone who uses the code-base later.

A typical .env file looks like this (it’s a collection of key=value pairs)

# The Node environment
NODE_ENV=development

--

--

Sahu
Sahu

Written by Sahu

All opinions shared are personal and not influenced by my Employer • Senior Software Engineer @ McKinsey & Company

No responses yet