Skip to content

hjfitz/local-env-var

Repository files navigation

Environment Variable Loader

Loading .env in to process.env

Codacy Badge Bless npm

Intro

This program strives to be a minimal way of loading variables from a configuration file (.env), and attaches them to process.env.

This works similarly to running your program with heroku local running dotenv.parse().

Prerequisites

All you need for this is a file named .env. Its contents should look like this:

CONTENTFUL_KEY=somesecretkey
CONTENTFUL_SPACE=somespaceurl
SECRET_API_KEY_THAT_WONT_GET_POSTED_TO_GIT=whoops

Usage

Simply load the library!

// ES6 imports
import 'local-env-var';
// Node module require
require('local-env-var');