Description
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.
node-config alternatives and similar modules
Based on the "Command Line Utilities" category.
Alternatively, view node-config alternatives based on common mentions on social networks and blogs.
-
nvm
Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions -
Inquirer.js
A collection of common interactive command line user interfaces. -
KeyboardJS
A JavaScript library for binding keyboard combos without the pain of key codes and key combo conflicts. -
omelette
Omelette is a simple, template based autocompletion tool for Node and Deno projects with super easy API. (For Bash, Zsh and Fish) -
log-update
Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc. -
configstore
Easily load and persist config without having to think about where and how -
insight
Node.js module to help you understand how your tool is being used by anonymously reporting usage metrics to Google Analytics -
columnify
Create text-based columns suitable for console output. Supports cell wrapping. -
Javascript library for 2d geometry
Javascript library for 2d geometry -
string-width
Get the visual width of a string - the number of columns required to display it -
multispinner
Multiple, simultaneous, individually controllable spinners for concurrent tasks in Node.js CLI programs -
loud-rejection
Make unhandled promise rejections fail loudly instead of the default silent fail -
sudo-block
Block users from running your app with root permissions -
googleauth
Create and load persistent Google authentication tokens for command-line apps -
licenseye
Node.js CLI tool to visualize an aggregate list of your dependencies' licenses -
cron-to-quartz
Node.js library to convert unix or linux CRON syntax to Quartz Scheduler
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of node-config or a related project?
README
Configure your Node.js Applications
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.
Articles
- 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 markstos iMoses elliotttf jfelege leachiM2k josx enyo leosuncin arthanzel eheikes th507 Osterjour cunneen nsabovic BadgerBadgerBadgerBadger simon-scherzinger leonardovillela axelhzf benkroeger fgheorghe IvanVergiliev jpwilliams jaylynch jberrisch kgoerlitz bertho-zero NguyenMatthieu nitzan-shaked robertrossmann
License
May be freely distributed under the MIT license.
Copyright (c) 2010-2022 Loren West and other contributors
*Note that all licence references and agreements mentioned in the node-config README section above
are relevant to that project's source code only.