envfile

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

envfile

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

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

a=1
b:2
c = 3
d : 4
  1. Install Node.js
  2. npm install --save envfile
  1. See Browserify
// 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 

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

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

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