env-defaults
Env-defaults is zero-dependency module to load environment variables from file. Can compatibility use with dotenv
Install
npm install env-defaults
yarn add env-defaults
Usage
Javascript
const envDefault = require('env-defaults');
const { PORT, NODE_ENV, IS_PRODUCTION } = envDefault.load({
PORT: 3000,
NODE_ENV: 'development',
IS_PRODUCTION: false,
});
TypeScript
import { load } from 'env-defaults';
const { PORT, NODE_ENV, IS_PRODUCTION } = load({
PORT: 3000,
NODE_ENV: 'development',
IS_PRODUCTION: false,
});
Compatibility use with dotenv
Config dot env if nessessary.
require('dotenv').config();