# dynamic-dotenv

> A version of dotenv that will watch the dotenv file and reload it if it changes

Latest version **1.0.0** (published 2019-08-13) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-08-13 |
| First published | 2019-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Adriaan Callaerts |
| Maintainers | call-a3 |
| Keywords | dotenv, dynamic, watch, env, .env, environment, variables, config, settings |

## Links

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

## Dependencies (2)

- [dotenv](https://npm.io/package/dotenv.md) ^8.0.0
- [chokidar](https://npm.io/package/chokidar.md) ^3.0.2

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

- 1.0.0 (latest) — 2019-08-13

## README

# dynamic-dotenv

[![NPM](https://img.shields.io/npm/v/dynamic-dotenv.svg)](https://www.npmjs.com/package/dynamic-dotenv)
[![Travis](https://img.shields.io/travis/call-a3/dynamic-dotenv.svg)](https://travis-ci.com/call-a3/dynamic-dotenv)
[![Codecov](https://img.shields.io/codecov/c/github/call-a3/dynamic-dotenv.svg)](https://codecov.io/gh/call-a3/dynamic-dotenv)
[![Greenkeeper badge](https://badges.greenkeeper.io/call-a3/dynamic-dotenv.svg)](https://greenkeeper.io/)
[![David](https://img.shields.io/david/call-a3/dynamic-dotenv.svg)](https://david-dm.org/call-a3/dynamic-dotenv)
[![David Dev](https://img.shields.io/david/dev/call-a3/dynamic-dotenv.svg)](https://david-dm.org/call-a3/dynamic-dotenv?type=dev)

Like dotenv, but dynamic!

## Installing

```bash
# npm
npm install -s dynamic-dotenv

# yarn
yarn add dynamic-dotenv
```

## Usage

This package essentially behaves the same as using the manual initialisation of the [dotenv package](https://www.npmjs.com/package/dotenv).
The main difference to dotenv, is that the response value is an EventEmitter.
It will emit "change" events every time the loaded env file changes, as well as update the process.env values when that happens.
If an error occurs, either from filesystem interaction or from dotenv, it will also be emitted as an "error" event.

```js
import dynamicDotenv from 'dynamic-dotenv'

const dd = dynamicDotenv(/* you can pass the same options as dotenv here */)
// process.env now contains the values in your .env file

dd.on('change', () => {
  // this event will be emitted every time the .env file changes
})
```

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