@mullerstd/load-env
The easiest way to load .env files in your project
Install
yarn add @mullerstd/load-env
OR
npm install @mullerstd/load-env
Usage
Create a .env
file in the project's root directory.
DATABASE_URL="postgresql://user:secret@localhost:5432/db"
You can load variables in two ways:
Use CLI wrapper
npx load-env node seed.js
or package.json script
{
"scripts": {
"start": "load-env node start.js"
}
}
Load env's programmatically
import { loadEnv } from '@mullerstd/load-env'
const env = loadEnv()
const dbUrl = env.DATABASE_URL
...