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
npm
npm install configMethods
No methods match this filter.
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:
exception(README 未具名)(未具名异常:官方 README 只称 exception,未给出类名) — official text: “config.get()will throw an exception for undefined keys to help catch typos and missing values.” (source: https://raw.githubusercontent.com/node-config/node-config/master/README.md, fetched 2026-11-08T19:58:23+08:00)
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 均未取到).
config.util.toObject→ signature from https://raw.githubusercontent.com/wiki/node-config/node-config/Using-Config-Utilities.md; official text: “Returns a raw version of the current config object, or any part of the config if provided, deeply copied without theget,hasandutilfunctions. If config is not provided (undefined), the current config object i”
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.
Report a problem with this API docOpens a pre-filled issue on GitHub.