8th May, 2014

Storing NodeJS app config in environment

Storing application config in the environment variables helps separate development, testing and production configuration.

I've been using dotenv to store my local development settings in a .env file (which I don't copy to production)

Simply put


at the top of your app.js file, then create a .env file with


like so.

Now KEY is accessable in your application using process.env.KEY


The opinions expressed here are my own and not those of my employer.