# node-env-file

> Parse and load environment files (containing ENV variable exports) into Node.js environment, i.e. `process.env`.

Latest version **0.1.8** (published 2015-11-13) · 0 weekly downloads

## Install

```sh
npm install node-env-file
pnpm add node-env-file
yarn add node-env-file
bun add node-env-file
```

## 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.1.8 |
| Published | 2015-11-13 |
| First published | 2013-09-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 117 |
| Author | Jonas Grimfelt |
| Maintainers | grimen |
| Keywords | process, env, file, files, .env, ENV, process.env, parse, load, export, exports |

## Links

- npm: https://www.npmjs.com/package/node-env-file
- Repository: https://github.com/grimen/node-env-file
- Issues: https://github.com/grimen/node-env-file/issues
- npm.io page: https://npm.io/package/node-env-file

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 0.1.8 (latest) — 2015-11-13
- 0.1.7 — 2015-02-18
- 0.1.6 — 2015-02-12
- 0.1.5 — 2015-02-10
- 0.1.4 — 2014-09-23
- 0.1.3 — 2014-04-23
- 0.1.2 — 2014-04-23
- 0.1.0 — 2013-09-30

## README

# NODE-ENV-FILE [![Build Status](https://secure.travis-ci.org/grimen/node-env-file.svg)](http://travis-ci.org/grimen/node-env-file)

Parse and load environment files (containing ENV variable exports) into Node.js environment, i.e. `process.env`.


## Example

**`.env`**

```bash
  # some env variables

  FOO=foo1
  BAR=bar1
  BAZ=1
  QUX=
  # QUUX=
```

**`.env2`**

```bash
  # some env variables using exports syntax

  exports FOO=foo2
  exports BAR=bar2
  exports BAZ=2
  exports QUX=
  # exports QUUX=

```

**`index.js`**

```javascript
  var assert = require('assert');
  var env = require('node-env-file');

  process.env.FOO = "defaultfoo";

  // Load any undefined ENV variables form a specified file.
  env(__dirname + '/.env');
  assert.equal(process.env.FOO, "defaultfoo");
  assert.equal(process.env.BAR, "bar1");
  assert.equal(process.env.BAZ, "1");
  assert.equal(process.env.QUX, "");
  assert.equal(process.env.QUUX, undefined);

  // Load another ENV file - and overwrite any defined ENV variables.
  env(__dirname + '/.env2', {overwrite: true});
  assert.equal(process.env.FOO, "foo2");
  assert.equal(process.env.BAR, "bar2");
  assert.equal(process.env.BAZ, "2");
  assert.equal(process.env.QUX, "");
  assert.equal(process.env.QUUX, undefined);
```


## API

* `(filepath)`

    ```javascript
    env('./path/to/.env');
    ```

* `(filepath, options)`

    ```javascript
    env('./path/to/.env', {verbose: true, overwrite: true, raise: false, logger: console});
    ```


## Installation

```shell
  $ npm install node-env-file
```


## Test

**Local tests:**

```shell
  $ make test
```


## Examples

**Local examples:**

```shell
  $ make example
```


## Related Libraries

* **[node-env-flag](http://github.com/grimen/node-env-flag)**


## License

Released under the MIT license.

Copyright (c) [Jonas Grimfelt](http://github.com/grimen)

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/grimen/node-env-file/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

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