Skip to content

Loads environment variables from .env.${ENV_NAME} files

License

Notifications You must be signed in to change notification settings

nrotta/dotenvdotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Loads environment variables from .env.${ENV_NAME} files

Resources

License

Stars

Watchers

Forks

Packages

No packages published