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 🙏

© 2025 – Pkg Stats / Ryan Hefner

littleconf

v2.0.2

Published

Simple and small library for loading configuration files and options

Downloads

10

Readme

LittleConf

LittleConf is a simple library for loading project configuration files.

import { getConfig } from 'littleconf';
const config = await getConfig();

This will load a YAML configuration file named <PackageName>.conf or <PackageName>.conf.js from the package root directory. By default, the package name is discovered from the project's package.json file.

Config Defaults

LittleConf will also look for a file named <PackageName>-defaults.conf or <PackageName>-defaults.conf.js in the package root directory. This file is merged with the main config file and can supply defaults. By convention, the defaults file should be committed to the source repository, and the main config file should not.

Config Filename and Search Path

LittleConf looks for the main config file under the following namess. It uses the first one that applies:

  • The value of the filenameOverride option.
  • The value of the -c command-line argument.
  • The value of the environment variable PACKAGE_NAME_CONFIG.
  • The value of the filename option.
  • package-name.conf

If the above does not yield an absolute path, LittleConf first looks for the file in the package root directory, then in /etc.

Environments

In the config file, you can specify a set of configuration values that are only applied when a given "environment" is configured. The config file with environments looks like this:

foo: "banana"
bar: 12
environments:
	local:
		foo: "apple"
	prod:
		foo: "pear"

The envionment is normally selected using the NODE_ENV or PROJECT_NAME_ENV environment variable, but can also be selected using the following methods (the first that exists is used):

  • The environmentOverride option.
  • The --config-env command-line argument.
  • The PROJECT_NAME_ENV environment variable.
  • The NODE_ENV environment variable.
  • The defaultEnvironment option.
  • The default environment of "local"

Command-line Arguments

To allow LittleConf to handle command-line arguments, it needs to be supplied with the argv option. This can come from a standard argument parsing package like optimist or yargs.

const argv = require('yargs').argv;
const config = require('littleconf').getConfig({ argv: argv });

Individual Setting Overrides

Individual settings can be overridden using command-line arguments or environment variables. Environment variables are named PROJECT_NAME_CONFIG_SETTINGNAME and command-line arguments look like --config-setting-SETTINGNAME.

Options

These options can be supplied in the argument to getConfig().

  • argv - The set of command-line arguments.
  • projectName - The name of the project. Defaults to the name property in package.json.
  • environmentOverride - Force a specific config environment value.
  • cliArgumentEnvironment - The name of the CLI argument to use for selecting the config environment. Defaults to "config-env".
  • rootDir - The root directory of the project. By default this is determined by using require.main and traversing upwards until a package.json is found.
  • envVariableEnvironment - Selects a specific name for the environment variable to determine the config environment rather than the default of PROJECT_NAME_ENV.
  • defaultEnvironment - Sets the default config environment. Defaults to "local".
  • defaultsFilename - Sets the filename to use for the defaults file. Normally "projectname-defaults.conf".
  • filenameOverride - Forces the name/path of the main config file.
  • filename - Default name of the main config file. Defaults to "projectname.conf".
  • cliArgumentFile - Name of the command-line argument to specify the config file. Defaults to "c".
  • envVariableFile - Name of the environment variable to specify the config file. Defaults to PROJECT_NAME_CONFIG.