GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - node-config/node-config: Node.js Application Configuration

BranchesTags
Open more actions menu

Latest commit

 

History

893 Commits
893 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
benchmarks
benchmarks
 
 
lib
lib
 
 
media
media
 
 
test
test
 
 
tools
tools
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
.npmrc
.npmrc
 
 
.travis.yml
.travis.yml
 
 
History.md
History.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
parser.js
parser.js
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

config

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/parser, 'config/util/defer', and config/lib/util in addition to the main config entrypoint.

Articles

  • Configuration Files
    • Special features for JavaScript configuration files
  • Common Usage
  • Environment Variables
  • Reserved Words
  • Command Line Overrides
  • Multiple Node Instances
  • Sub-Module Configuration
  • Configuring from a DB / External Source
  • Securing Production Config Files
  • External Configuration Management Tools
  • Examining Configuration Sources
  • Using Config Utilities
  • Upgrading from Config 0.x
  • Webpack usage

Further Information

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

  • The wiki may have more pages which are not directly linked from here.
  • Review questions tagged with node-config on StackExchange. These are monitored by node-config contributors.
  • Search the issue tracker. Hundreds of issues have already been discussed and resolved there.

Contributors

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

License

May be freely distributed under the MIT license.

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

About

Node.js Application Configuration

Topics

configdeploymentpropertiesregistrysettingsstate

Resources

Readme
License
Activity
Custom properties

Stars

6.4k stars

Watchers

71 watching

Forks

515 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.