API Reference

node-config

Node.js configuration library that merges JSON, YAML, and environment overrides by deployment.

Official Documentation ↗
CompatibilityThis documentation covers version v3.37. Check the official docs for the latest API surface.

Installation

npmnpm install config

Methods

node-config loads a config directory and overlays environment-specific files and local overrides.

Key Features

  • Environment-specific config files
  • Local overrides excluded from git
  • Custom environment variables for overrides

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The official API reference declares the following error types:

API reference evidence

Fetched from official sources on 2026-11-08T19:58:23+08:00 via WebFetch https://raw.githubusercontent.com/node-config/node-config/master/README.md;WebFetch https://raw.githubusercontent.com/wiki/node-config/node-config/Using-Config-Utilities.md(types/index.d.ts 于 raw 与 jsdelivr 均未取到).

FAQ

How are environments selected?
The NODE_ENV value decides which default-<env>.json is layered in; NODE_CONFIG overrides at runtime with a JSON string.
Should local files be committed?
No. local.json and local-<env>.json are gitignored so developers keep machine-specific values out of the repository.
Can I use environment variables?
Yes. Set the custom-environment-variables file to map keys to env names, keeping secrets out of config files.