parse-dotenv
v2.1.0
Published
Zero dependency .env to object parser
Downloads
25,543
Maintainers
Readme
parse-dotenv
Zero-dependency .env to javascript object parser
Installation
npm install parse-dotenv --save
Usage
# .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
import parseEnv from "parse-dotenv";
const parsed = parseEnv();
console.log(parsed.DB_CONNECTION); // mysql
or provide a path (relative to project root) to env
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
{
emptyLines: false; // ignore empty lines in env
}
Related
- sync-dotenv - Keep your .env in sync with .env.example
LICENSE
This project is licensed under MIT