Back to rankings

node-config/node-config

JavaScript

Node.js Application Configuration

configstatedeploymentsettingspropertiesregistry
Star Growth
Stars
6.4k
Forks
510
Weekly Growth
Issues
6
2k4k6k
Feb 2011Mar 2016May 2021Jul 2026
Artifactsnpmnpm install node-config
README

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

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

Related repositories
ddgksf2013/ddgksf2013

墨鱼去广告计划 | QuantumultX 去广告 | 去开屏广告 | 应用净化 | 会员解锁 | 墨鱼配置 | 应用增强 | 网页优化 | 网盘资源 | 模块去广告 | 圈 X 配置 | Shadowrocket配置 | 墨鱼规则 | Clash配置 | 小火箭去广告 | 资源库 | AdBlock | 网页广告 | 不完全指北

adblockclash
t.me/ddgksf2021
13.3k579
h5bp/server-configs-nginx

Nginx HTTP server boilerplate configs

MIT Licensenginxnginx-configuration
11.6k1.5k
apple/pkl

A configuration as code language with rich validation and tooling.

JavaMavenApache License 2.0pkljava
pkl-lang.org
11.5k393
timarney/react-app-rewired

Override create-react-app webpack configs without ejecting

JavaScriptnpmMIT Licensereactcreate-react-app
9.8k420
TomWright/dasel

Unified querying, transformation, and modification of JSON, TOML, YAML, XML, INI, HCL, KDL and CSV.

GoGo ModulesMIT Licensejsonyaml
daseldocs.tomwright.me
8k170
google/jsonnet

Jsonnet - The data templating language

JsonnetApache License 2.0jsonnetconfiguration
jsonnet.org
7.5k474
caarlos0/env

A simple, zero-dependencies library to parse environment variables into structs

GoGo ModulesMIT Licensegolangenvironment-variables
pkg.go.dev/github.com/caarlos0/env/v11
6.3k280
ashleve/lightning-hydra-template

PyTorch Lightning + Hydra. A very user-friendly template for ML experimentation. ⚡🔥⚡

PythonPyPIpytorch-lightningproject-structure
5.3k761
sindresorhus/electron-store

Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc

JavaScriptnpmMIT Licensestorageuser-preferences
5k167
focus-creative-games/luban

luban是一个强大、易用、优雅、稳定的游戏配置解决方案。luban is a powerful, easy-to-use, elegant and stable game configuration solution.

C#MIT Licenseexcelcsv
code-philosophy.com
4.5k726
jonschlinkert/gray-matter

Smarter YAML front matter parser, used by metalsmith, Gatsby, Netlify, Assemble, mapbox-gl, phenomic, vuejs vitepress, TinaCMS, Shopify Polaris, Ant Design, Astro, hashicorp, garden, slidev, saber, sourcegraph, and many others. Simple to use, and battle tested. Parses YAML by default but can also parse JSON Front Matter, Coffee Front Matter, TOML Front Matter, and has support for custom parsers. Please follow gray-matter's author: https://github.com/jonschlinkert

JavaScriptnpmMIT Licenseyamlfront-matter
github.com/jonschlinkert
4.5k162
dynaconf/dynaconf

Configuration Management for Python ⚙

PythonPyPIMIT Licenseconfiguration-managementconfig
dynaconf.com
4.3k335