Node-config loads layered settings from files in your app and merges overrides from environment variables and command-line arguments. It provides a shared config interface used across many npm modules.
Overview
Node-config organizes deployment settings for Node.js programs using a hierarchy of defaults and environment-specific files. You define baseline values, then extend or override them for development, QA, staging, production, and other targets without changing application code paths.
Configuration can live in several on-disk formats, with JSON commonly shown in quick-start docs. The same keys can be superseded by environment variables, CLI flags, or external sources, giving one predictable API for reading values inside your app and dependent packages.
Access helpers such as get throw when a key is missing, which helps catch typos early, while has tests existence without loading a default. Production overrides merge with defaults so individual fields can differ per environment, as in database host coming from a production file while other db fields stay from defaults.
TypeScript typings ship under types/ with subpath declarations for parser and utility entrypoints. Documentation covers defer utilities, webpack usage, securing production files, and loading from databases or external managers.
Key features
- Layered default and environment config files
- Environment variable and CLI overrides
- Multiple supported config file formats
- config.get and config.has accessors
- Shared interface across npm dependencies
- TypeScript declarations with subpath typings
- Guidance for multi-instance deployments
Use cases
- Separating development and production settings
- Centralizing database and server port configuration
- Overriding secrets via environment variables
- Sharing config patterns across Node packages
- Type-safe configuration in TypeScript apps