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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-env-conf

v3.0.1

Published

configuration manager that keys off of the node environment

Downloads

11

Readme

Node-env-conf

Node-env-conf provides a wrapper to the popular nconf npm library.

Usage

Node-env-conf extends nconf with a simple initialization function to setup nconf and load either default or custom configuration files.

Calling init will always setup nconf with the process.argv and process.env variables.

Default configuration

// main project file (e.g., app.js);
var envConf = require('node-env-conf');

// load default configuration
envConf.init();

// loaded
// * [PROJECT_ROOT]/private-config.json
// * [PROJECT_ROOT]/env/[NODE_ENV].json
// * [PROJECT_ROOT]/config.json
// * [PROJECT_ROOT]/package.json

Custom configuration

// main project file (e.g., app.js);
var
  path = require('path'),
  envConf = require('node-env-conf');

// load custom configuration
envConf.init([
  {
    name: 'other_config.json',
    path: path.resolve(__dirname, '..', '..', 'other', 'configs')
  }
]);

// loaded
// * [PROJECT_ROOT]/other/configs/other_config.json

API

Node-env-conf extends the nconf API, so all properties and methods available on nconf will be available through node-env-conf.

#init([configs])

Initializes nconf with the process.argv and process.env variables. Loads in either the default configuration files or the custom files specified by the configs argument.

The order in which the configuration files is specified determines the priority of the configuration values. In other words, whichever file is loaded in first will get highest priority, and whichever is loaded in last will get lowest priority. Any key/value collisions will be resolved to the highest priority file. This can be a convenient means of overriding global configurations with custom environment ones.

The default load order is:

  • private-config.json
  • [NODE_ENV].json
  • config.json
  • package.json

Arguments

  1. [configs] (Array): Optional Array of config Objects:
  • name (String): File name
  • path (String): Resolve path to the directory containing the file

Returns

Node-env-conf object

Testing

Tests can be run via npm test