1.0.0 • Published 3 years ago

read-dotenv v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

read-dotenv

read a .env file into an object

Installation

$ npm install read-dotenv --save

Usage

import dotenv from 'read-dotenv'

Example

# .env
PORT=7777
HOST=my.host.com
// app.js
import dotenv from 'read-dotenv'

const env = dotenv({
  PORT: 3000,
  HOST: 'localhost',
  SOME: 'other option'
})

// `env` is now:
{
  PORT: 7777,
  HOST: 'my.host.com',
  SOME: 'other option',
}

API

dotenv(env?, root?): Record<string, any>

Parameters

NameTypeDescription
envRecord<string, any>The environment default object
rootstringThe path where .env lives (default: process.cwd())

License

MIT