# parse-dotenv

> Zero dependency .env to object parser

Latest version **2.1.0** (published 2019-11-22) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2019-11-22 |
| First published | 2019-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Luqman Olushi |
| Maintainers | codeshifu |
| Keywords | env, env object, parse env, env parser, dotenv, dotenv parser |

## Links

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

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

- 2.1.0 (latest) — 2019-11-22
- 2.0.1 — 2019-04-07
- 2.0.0 — 2019-04-06
- 1.0.2 — 2019-04-06
- 1.0.1 — 2019-04-06

## README

# parse-dotenv

> Zero-dependency .env to javascript object parser

![Travis (.org)](https://img.shields.io/travis/codeshifu/parse-dotenv.svg)
[![Coverage Status](https://coveralls.io/repos/github/codeshifu/parse-dotenv/badge.svg?branch=master)](https://coveralls.io/github/codeshifu/parse-dotenv?branch=master)

## Installation

```bash
npm install parse-dotenv --save
```

## Usage

```bash
# .env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
```

```javascript
import parseEnv from "parse-dotenv";

const parsed = parseEnv();

console.log(parsed.DB_CONNECTION); // mysql
```

or provide a path (relative to project root) to env

```javascript
const parseEnv = require("parse-dotenv");

const parsed = parseEnv(".env.example");
console.log(parsed.DB_PORT); // 3306
```

## API

### path

Type: `string`

Default: `path.resolve(process.cwd(), '.env')`

### opts

Type: `Object`

#### opts.emptyLines

Type: `boolean`

Default: false

```javascript
{
  emptyLines: false; // ignore empty lines in env
}
```

## Related

- [sync-dotenv](https://github.com/codeshifu/sync-dotenv) - Keep your .env in
  sync with .env.example

## LICENSE

This project is licensed under [MIT](https://github.com/codeshifu/parse-env/blob/master/LICENSE)

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