# dotenv-ex

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

Latest version **0.2.0** (published 2018-04-20) · Unlicense license · 0 weekly downloads

## Install

```sh
npm install dotenv-ex
pnpm add dotenv-ex
yarn add dotenv-ex
bun add dotenv-ex
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-04-20 |
| First published | 2018-04-20 |
| Weekly downloads | 0 |
| License | Unlicense |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 67.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrzej Lichnerowicz |
| Maintainers | unjello |

## Links

- npm: https://www.npmjs.com/package/dotenv-ex
- Repository: https://github.com/unjello/dotenv-ex
- Homepage: https://github.com/unjello/dotenv-ex#readme
- Issues: https://github.com/unjello/dotenv-ex/issues
- npm.io page: https://npm.io/package/dotenv-ex

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^3.1.0
- [dotenv](https://npm.io/package/dotenv.md) ^5.0.1
- [dotenv-expand](https://npm.io/package/dotenv-expand.md) ^4.2.0

## Recent versions

- 0.2.0 (latest) — 2018-04-20

## README

[![Build Status][travis_badge]][travis_link] [![js-standard-style][js_standard_badge]][js_standard_link]

# 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:

```javascript
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`
1. `.env.production`, `.env.development`, `.env.test`
1. `.env.local`
1. `.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:

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

or your own list of files:

```javascript
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

- https://github.com/motdotla/dotenv - used under-the-hood, even tho it discourages using multiple `.end` files, let alone source controlling them
- https://github.com/motdotla/dotenv-expand - also used, for variable expansion
- https://github.com/facebook/create-react-app - `react-scripts` was immediate source of inspiration
- https://github.com/bkeepers/dotenv - hierarchy of `.env` files based on this ruby gem


[js_standard_badge]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[js_standard_link]:  https://github.com/feross/standard
[travis_badge]: https://travis-ci.org/unjello/dotenv-ex.svg?branch=master
[travis_link]:  https://travis-ci.org/unjello/dotenv-ex

---
_Source: https://npm.io/package/dotenv-ex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
