Loads environment variables from .env

DotEnv for Node.js

DotEnv loads environment variables from .env into your ENV.

As early as possible in your application require dotenv and load the .env variables.

DotEnv = require('dotenv-node');
new DotEnv();

Add your application configuration to a .env file in the root of your project:


When your application loads, these variables will be available via process.env:

  • The Twelve Factor App
  • bkeepers/dotenv - the original, written in Ruby -
  • scottmotte/dotenv - the first take on this, written in JavaScript -
  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
npm install
npm test