Skip to content


Subversion checkout URL

You can clone with
Download ZIP

ESON JSON Configuration

Douglas Christopher Wilson edited this page · 6 revisions

The Extended-JSON library allows you to transform JSON using plugins, and comes with several plugins that are very useful for app configuration.

To get started, add eson:

$ npm install eson --save

Then require eson, and select a configuration file based on the __NODE_ENV__ environment variable (which defaults to 'development'):

var express = require('express');
var app = express();
var eson = require('eson');
var file = __dirname + '/config/' + app.get('env') + '.json';

The file variable will then contain a path to ./config/development.json, ./config/production.json, etc.

Two plugins are used here: .env() to read config from environment variables, and .args() to read from ARGV.

var conf = eson()

Now, if you had { "log path": "/tmp/app.log" } in development.json, you could override this with a __MYAPP_LOG_PATH=/some/path__ environment variable, or with node app --log-path /some/path.

Something went wrong with that request. Please try again.