0.2.0 • Published 6 years ago

dotenv-ex v0.2.0

Weekly downloads
1
License
Unlicense
Repository
github
Last release
6 years ago

Build Status js-standard-style

dotenv-ex

  • Loads environment variables from hierarchy of .env files for Node.js projects.

How to use it?

Use this somewhere possibly early in your program:

require('dotenv-ex')();

this will load files based on NODE_ENV. If it's not set, production is used as default. The files are loaded in following order:

  1. .env.production.local, .env.development.local
  2. .env.production, .env.development, .env.test
  3. .env.local
  4. .env

.env.local is not used in test environment, as well as there is no .env.test.local. This is because, I believe tests should not be specific to local environment, and should work for everyone working on the module, in the very same, reproducible way.

You can also override default files, by specifying only one file to load:

require('dotenv-ex')({env: '.env.one'})

or your own list of files:

require('dotenv-ex')({env: ['.env.one', '.env.moar']})

Keep in mind, that environment variables specified in the files, are case sensitive.

License

  • Unlicense (~Public Domain)

Related Work