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

Configure your Node.js Applications

NPM   Build Status   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.

Articles

Further Information

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

Contributors

lorenwest markstos iMoses elliotttf jfelege leachiM2k
josx enyo leosuncin arthanzel eheikes th507
Osterjour cunneen nsabovic BadgerBadgerBadgerBadger simon-scherzinger leonardovillela
axelhzf benkroeger fgheorghe IvanVergiliev jpwilliams jaylynch
jberrisch kgoerlitz bertho-zero NguyenMatthieu nitzan-shaked robertrossmann

License

May be freely distributed under the MIT license.

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

Current Tags

  • 3.3.9                                ...           latest (2 years ago)

115 Versions

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

Copyright 2013 - present © cnpmjs.org | Home |