dotenvdotenv

0.6.2 • Public • Published

dotenvdotenv

Zero-dependency lib that loads environment variables from .env.${ENV_NAME} files

BuildStatus NPM version Code Climate

Install

npm install dotenvdotenv --save

Usage

Require the lib as early as possible in your app

require('dotenvdotenv');

Create the .env.dev and .env.test files in the root directory and add environment variables on new lines as KEY=VALUE

For example:

REDIS_HOST=localhost
REDIS_PORT=32776

The vars are now available on process.env

redis: {
  host: process.env.REDIS_HOST,
  port: process.env.REDIS_PORT
}

If the .env.${ENV_NAME} files do no exist, an error will be raised

Supports

Node:

  • v0.10
  • v0.12
  • v4
  • v5
  • v6

FAQ

Should I commit my .env.${ENV_NAME} files?

No. .env.${ENV_NAME} files should not be committed to version control. Your production environment should use the environment variables

What happens to existing environment variables?

Existing environment variables will not be overwritten

Readme

Keywords

none

Package Sidebar

Install

npm i dotenvdotenv

Weekly Downloads

7

Version

0.6.2

License

ISC

Last publish

Collaborators

  • nrotta