config
Configuration control for production node deployments
Last updated 2 months ago by jdmarshall .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install config 
SYNC missed versions from official npm registry.

Configure your Node.js Applications

npm package Downloads Issues

Release Notes

Introduction

Node-config organizes hierarchical configurations for your app deployments.

It lets you define a set of default parameters, and extend them for different deployment environments (development, qa, staging, production, etc.).

Configurations are stored in configuration files within your application, and can be overridden and extended by environment variables, command line parameters, or external sources.

This gives your application a consistent configuration interface shared among a growing list of npm modules also using node-config.

Project Guidelines

  • Simple - Get started fast
  • Powerful - For multi-node enterprise deployment
  • Flexible - Supporting multiple config file formats
  • Lightweight - Small file and memory footprint
  • Predictable - Well tested foundation for module and app developers

Quick Start

The following examples are in JSON format, but configurations can be in other file formats.

Install in your app directory, and edit the default config file.

$ npm install config
$ mkdir config
$ vi config/default.json
{
  // Customer module configs
  "Customer": {
    "dbConfig": {
      "host": "localhost",
      "port": 5984,
      "dbName": "customers"
    },
    "credit": {
      "initialLimit": 100,
      // Set low for development
      "initialDays": 1
    }
  }
}

Edit config overrides for production deployment:

 $ vi config/production.json
{
  "Customer": {
    "dbConfig": {
      "host": "prod-db-server"
    },
    "credit": {
      "initialDays": 30
    }
  }
}

Use configs in your code:

const config = require('config');
//...
const dbConfig = config.get('Customer.dbConfig');
db.connect(dbConfig, ...);

if (config.has('optionalFeature.detail')) {
  const detail = config.get('optionalFeature.detail');
  //...
}

config.get() will throw an exception for undefined keys to help catch typos and missing values. Use config.has() to test if a configuration value is defined.

Start your app server:

$ export NODE_ENV=production
$ node my-app.js

Running in this configuration, the port and dbName elements of dbConfig will come from the default.json file, and the host element will come from the production.json override file.

TypeScript

Type declarations are published under types/ and resolved via typesVersions. Subpath typings are included for config/async, config/defer, config/parser, config/raw, and config/lib/util in addition to the main config entrypoint.

Articles

Further Information

If you still don't see what you are looking for, here are some more resources to check:

Contributors

lorenwest jdmarshall markstos i­Moses elliotttf mdkitzman
jfelege leachi­M2k josx enyo leosuncin arthanzel
leonardovillela jeremy-daley-kr simon-scherzinger Badger­Badger­Badger­Badger nsabovic cunneen
Osterjour th507 tiny-rac00n eheikes fgheorghe roncli
superoven airdrummingfool wmertens Xadilla­X inside dsbert

License

May be freely distributed under the MIT license.

Copyright (c) 2010-2026 Loren West and other contributors

Current Tags

  • 4.4.1                                ...           latest (2 months ago)
  • 5.0.0-alpha.1                                ...           preview (a month ago)

129 Versions

  • 5.0.0-alpha.1                                ...           a month ago
  • 5.0.0-alpha.0                                ...           a month ago
  • 4.4.1                                ...           2 months ago
  • 4.4.0                                ...           2 months ago
  • 4.3.0                                ...           2 months ago
  • 4.2.1                                ...           2 months ago
  • 4.2.0                                ...           3 months ago
  • 4.1.1                                ...           8 months ago
  • 4.1.0                                ...           9 months ago
  • 4.0.1                                ...           9 months ago
  • 4.0.0                                ...           a year ago
  • 3.3.12                                ...           2 years ago
  • 3.3.11                                ...           2 years ago
  • 3.3.10                                ...           2 years ago
  • 3.3.9                                ...           3 years ago
  • 3.3.8                                ...           4 years ago
  • 3.3.7                                ...           4 years ago
  • 3.3.6                                ...           5 years ago
  • 3.3.4                                ...           5 years ago
  • 3.3.3                                ...           5 years ago
  • 3.3.2                                ...           6 years ago
  • 3.3.1                                ...           6 years ago
  • 3.3.0                                ...           6 years ago
  • 3.2.6                                ...           6 years ago
  • 3.2.5                                ...           6 years ago
  • 3.2.4                                ...           6 years ago
  • 3.2.3                                ...           7 years ago
  • 3.2.2                                ...           7 years ago
  • 3.2.1                                ...           7 years ago
  • 3.2.0                                ...           7 years ago
  • 3.1.0                                ...           7 years ago
  • 3.0.1                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 2.0.2                                ...           7 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.31.0                                ...           8 years ago
  • 1.30.0                                ...           8 years ago
  • 1.29.4                                ...           8 years ago
  • 1.29.3                                ...           8 years ago
  • 1.29.2                                ...           8 years ago
  • 1.29.1                                ...           8 years ago
  • 1.29.0                                ...           8 years ago
  • 1.28.1                                ...           8 years ago
  • 1.28.0                                ...           8 years ago
  • 1.27.0                                ...           8 years ago
  • 1.26.2                                ...           9 years ago
  • 1.26.1                                ...           9 years ago
  • 1.25.1                                ...           9 years ago
  • 1.25.0                                ...           9 years ago
  • 1.24.0                                ...           9 years ago
  • 1.23.0                                ...           9 years ago
  • 1.21.0                                ...           10 years ago
  • 1.20.4                                ...           10 years ago
  • 1.20.3                                ...           10 years ago
  • 1.20.2                                ...           10 years ago
  • 1.20.1                                ...           10 years ago
  • 1.20.0                                ...           10 years ago
  • 1.19.0                                ...           10 years ago
  • 1.17.1                                ...           10 years ago
  • 1.17.0                                ...           10 years ago
  • 1.16.0                                ...           11 years ago
  • 1.15.0                                ...           11 years ago
  • 1.14.0                                ...           11 years ago
  • 1.13.0                                ...           11 years ago
  • 1.12.0                                ...           11 years ago
  • 1.11.0                                ...           11 years ago
  • 1.10.0                                ...           11 years ago
  • 1.9.0                                ...           11 years ago
  • 1.8.1                                ...           11 years ago
  • 1.8.0                                ...           11 years ago
  • 1.7.0                                ...           11 years ago
  • 1.6.0                                ...           11 years ago
  • 1.5.0                                ...           11 years ago
  • 1.4.0                                ...           11 years ago
  • 1.3.0                                ...           11 years ago
  • 1.2.4                                ...           12 years ago
  • 1.2.3                                ...           12 years ago
  • 1.2.2                                ...           12 years ago
  • 1.2.1                                ...           12 years ago
  • 1.2.0                                ...           12 years ago
  • 1.1.0                                ...           12 years ago
  • 1.0.2                                ...           12 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
  • 0.4.37                                ...           12 years ago
  • 0.4.36                                ...           12 years ago
  • 0.4.35                                ...           12 years ago
  • 0.4.34                                ...           12 years ago
  • 0.4.33                                ...           12 years ago
  • 0.4.32                                ...           12 years ago
  • 0.4.31                                ...           12 years ago
  • 0.4.30                                ...           13 years ago
  • 0.4.29                                ...           13 years ago
  • 0.4.28                                ...           13 years ago
  • 0.4.27                                ...           13 years ago
  • 0.4.26                                ...           13 years ago
  • 0.4.25                                ...           13 years ago
  • 0.4.24                                ...           13 years ago
  • 0.4.23                                ...           13 years ago
  • 0.4.22                                ...           13 years ago
  • 0.4.21                                ...           13 years ago
  • 0.4.20                                ...           13 years ago
  • 0.4.19                                ...           13 years ago
  • 0.4.18                                ...           13 years ago
  • 0.4.17                                ...           14 years ago
  • 0.4.16                                ...           14 years ago
  • 0.4.15                                ...           14 years ago
  • 0.4.14                                ...           14 years ago
  • 0.4.13                                ...           14 years ago
  • 0.4.12                                ...           14 years ago
  • 0.4.11                                ...           14 years ago
  • 0.4.10                                ...           14 years ago
  • 0.4.9                                ...           14 years ago
  • 0.4.8                                ...           14 years ago
  • 0.4.7                                ...           14 years ago
  • 0.4.6                                ...           14 years ago
  • 0.4.5                                ...           14 years ago
  • 0.4.4                                ...           14 years ago
  • 0.4.3                                ...           15 years ago
  • 0.4.2                                ...           15 years ago
  • 0.4.1                                ...           15 years ago
  • 0.4.0                                ...           15 years ago
  • 0.2.9                                ...           15 years ago
  • 0.2.8                                ...           15 years ago
  • 0.2.7                                ...           15 years ago
  • 0.2.3                                ...           15 years ago
  • 0.2.5                                ...           15 years ago
  • 0.2.4                                ...           15 years ago
Downloads
Today 0
This Week 0
This Month 112
Last Day 0
Last Week 112
Last Month 0
Dependencies (1)
Dev Dependencies (15)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |