Application configuration on #nodejs with #convict

Oscar Brito

I'm definitively trying Convict to solve some configurations issues like:

  • Most applications will have at least a few different deployment environments, each with their own configuration needs.  
  • Including credentials and sensitive information in source can be problematic. 
  •  Debug / Release configurations 

Configuration example:

var convict = require('convict');

// define a schema
var conf = convict({
env: {
doc: "The applicaton environment.",
format: ["production", "development", "test"],
default: "development",
env: "NODEENV"
ip: {
doc: "The IP address to bind.",
format: "ipaddress",
default: "",
env: "IP
port: {
doc: "The port to bind.",
format: "port",
default: 0,
env: "PORT"

// load environment dependent configuration
var env = conf.get('env');
conf.loadFile('./config/' + env + '.json');

// perform validation

module.exports = conf;

Node.js facade:

var conf = require('./config.js');


Visit for more informations, contacts and news about Web Development.
See other blog posts at

Divhide purpose is to follow the HTML5 movement and contribute with applications which prove the quality of technology.

Feel free to contact divhide.