envfile

Parse and environment environment files (.env) with Node.js

npm install envfile
79 downloads in the last day
506 downloads in the last week
3 043 downloads in the last month

envfile

Build Status NPM version Flattr this project

Parse and environment environment files (.env) with Node.js

What is a envfile?

They generally are named .env or file.env and can look like:

a=1
b:2
c = 3
d : 4

Install

Backend

  1. Install Node.js
  2. npm install --save envfile

Frontend

  1. See Browserify

Usage

Via Node.js

// Include envfile
envfile = require('envfile');

// Parse an envfile path
envfile.parseFile('file.env', function(err,obj){});  // async
result = envfile.parseFileSync('file.env');  // sync

// Parse an envfile string
envfile.parse(src, function(err,obj){});  // async
result = envfile.parseSync(src);  // sync

// Stringify a javascript object to an envfile string
envfile.stringify(obj, function(err,str){});  // async
result = envfile.stringifySync(obj);  // sync

Via the Command Line

Requires a global installation of envfile: npm install -g envfile

# envfile to JSON
echo -e "a=1\nb:2" | envfile2json > config.json

# JSON to envfile
echo '{"a":1,"b":2}' | json2envfile > config.env

History

You can discover the version history inside the History.md file

License

Licensed under the incredibly permissive MIT License
Copyright © 2013+ Bevry Pty Ltd

npm loves you