0.6.2 • Published 9 years ago
dotenvdotenv v0.6.2
dotenvdotenv
Zero-dependency lib that loads environment variables from .env.${ENV_NAME} files
Install
npm install dotenvdotenv --saveUsage
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=32776The 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