DEV Community

Haikel Fazzani
Haikel Fazzani

Posted on

Envn

💨 Envn is a zero-dependency module that loads environment variables from a .env file into process.env.

Envn Envn
Envn Envn

Install

$ npm install envn
// or via Yarn
$ yarn add envn
Enter fullscreen mode Exit fullscreen mode

Usage

const envn = require('envn');
Enter fullscreen mode Exit fullscreen mode

Methods && Examples

const config = {
  // prefix of start name of env or any file contains environnement variables
  prefix: '.env',

  // default: process.env.NODE_ENV
  // developement | production | test -> this will load file .env.developement
  mode: 'developement'
}

// Envn method loads variables into process.env and also returns an object
envn(config?: Object) : Object

// env file example
REDIS:
  API_KEY=xxxx

console.log(process.env.REDIS_API_KEY);
Enter fullscreen mode Exit fullscreen mode

Notes

License

Released under the MIT license

Top comments (0)