parse-dotenv
Zero-dependency .env to javascript object parser
Installation
npm install parse-dotenv --save
Usage
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);
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);
API
path
Type: string
Default: path.resolve(process.cwd(), '.env')
opts
Type: Object
opts.emptyLines
Type: boolean
Default: false
{
emptyLines: false;
}
Related
LICENSE
This project is licensed under MIT