Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nconf

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nconf

Hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging.

  • 0.6.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
679K
decreased by-10.14%
Maintainers
3
Weekly downloads
 
Created

What is nconf?

nconf is a hierarchical node.js configuration with support for multiple sources. It allows you to manage configuration settings for your application from various sources such as command-line arguments, environment variables, files, and even custom sources.

What are nconf's main functionalities?

Loading Configuration from Command-Line Arguments

This feature allows you to load configuration settings from command-line arguments. The `argv` method parses the command-line arguments and makes them available through the `nconf` object.

const nconf = require('nconf');
nconf.argv();
console.log(nconf.get('someArg'));

Loading Configuration from Environment Variables

This feature allows you to load configuration settings from environment variables. The `env` method reads the environment variables and makes them accessible through the `nconf` object.

const nconf = require('nconf');
nconf.env();
console.log(nconf.get('NODE_ENV'));

Loading Configuration from a File

This feature allows you to load configuration settings from a file. The `file` method reads the specified file and makes its contents available through the `nconf` object.

const nconf = require('nconf');
nconf.file({ file: 'config.json' });
console.log(nconf.get('database:host'));

Setting Default Values

This feature allows you to set default configuration values. The `defaults` method sets the default values that will be used if no other source provides a value for a given key.

const nconf = require('nconf');
nconf.defaults({ 'port': 3000 });
console.log(nconf.get('port'));

Overriding Configuration Values

This feature allows you to override configuration values. The `overrides` method sets values that will take precedence over any other source.

const nconf = require('nconf');
nconf.overrides({ 'port': 8080 });
console.log(nconf.get('port'));

Other packages similar to nconf

Keywords

FAQs

Package last updated on 10 Jul 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc