npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-config-manager

v2.1.2

Published

A configuration manager for NodeJS. It helps you to organize your project and the different configurations of your environments.

Readme

Config manager Build Status Coverage Status

A configuration manager for NodeJS. It helps you to organize your project and the different configurations of your environments.

Installation

npm install --save node-config-manager

Usage

Structure

In a project, it's often necessary to have multiple environments (test, development, preproduction, production, etc.). ConfigManager offers a simple and intuitive architecture to organize it.

Example :

config/ 
    release/        (release env)
        logger.yaml
        db.json
    develop/        (develop env)
        logger.json
        db.js
    test/           (test env)
        db.json
    logger.js       (default logger configuration)
    db.js           (default db configuration)
    lambda.json     (default lambda configuration)

The config directory can be overridden by environment variables (NODE_CONFIG_DIR='./config') or when ConfigManager is initialized (#ConfigManager.prototype.init) .

Initialize

Environment variables

Name | Type | Default | Description -----------|-----------|------------|------------ NODE_CONFIG_DIR | String | ./config | Config directory path NODE_ENV | String | -- | Node environment NODE_CAMEL_CASE | Boolean | false | Naming convention of variables

Method init

If you don't like to configure with environment variables, you can initialize the different variables in JavaScript by using prototype init method.

var cfgManager = require('node-config-manager'),
    options = {
		configDir: './config',
		env: 'test',
		camelCase: true
	};

cfgManager.init(options);

Manage your configurations

After the configuration of the module, you can use the configuration store everywhere.

Add a configuration

In the first step, ConfigManager will search for the config file which matches with the current environment.

Example - test environment :

config/ 
  test/           (test env)
     db.json
  logger.js       (default logger configuration)
  db.js           (default db configuration)
var cfgManager = require('node-config-manager');

cfgManager.addConfig('db') //Load config/test/db.json
		  .addConfig('logger'); // Load config/logger.js

In the second step, ConfigManager will replace the loaded configurations by environment variables if they exist.

Example - app.json :

{
  "host": "localhost",
  "port": 80,
  "fstKey": {
	"sndKey": "custom_key_1",
	"copyHost": "custom_key_2"
  }
}

And with the following environment variables :

export APP__HOST="127.0.0.1"
export APP__FST_KEY__SND_KEY="anyKey"
export APP__FST_KEY__COPY_HOST="${APP__HOST}"

Result :

{
  "host": "127.0.0.1",
  "port": 80,
  "fstKey": {
	"sndKey": "anyKey",
	"copyHost": "127.0.0.1"
  }
}

Get a configuration

After adding your configuration, there are two methods to get your configuration :

var appCfgByGetConfig = cfgManager.getConfig('app'),
	appCfgByMethod = cfgManager.method.App();

console.log(appCfgByGetConfig.host); //127.0.0.1
console.log(appCfgByMethod.port); //80

If the config doesn't exist :

  • first case : return "null",
  • second case : throw exception "undefined is not a function"

Remove a configuration

You can delete a configuration with the removeConfig method.

cfgManager.removeConfig('app');

Type inference for environment variables

Environment variables cannot be typed. ConfigManager will try to infere the type, for example APP__HOST=127.0.0.1 will be parsed as a string and APP_PORT=8080 as a number.
You can override this type inference with type prefixes in environment variables : APP_PORT=ncm_string:8080 will return a string instead of number. The following type prefixes are supported:

  • ncm_string
  • ncm_boolean
  • ncm_number

Testing

From the repo root:

npm install
npm test