Skip to content

Latest commit

 

History

History
executable file
·
49 lines (42 loc) · 946 Bytes

README.md

File metadata and controls

executable file
·
49 lines (42 loc) · 946 Bytes

node-configs

build status node version

Loads a config based on environment variables config and node_env.

Config

Directory Structure

foo
+-- conf
|   +-- dev.json
|   +-- pro.json
|   `-- default.json
`-- package.json

default.json

{
  "person" : {
    "name" : "Bruce",
    "age"  : 30
  }
}

Usage

// Read from default.json
$node index.js
var config = require('config');
var name = config.get('person.name');
// Read from dev.json
$node index.js --NODE_ENV=dev
var config = require('config');
var name = config.get('person.name');
// Read from pro.json
$node index.js --NODE_ENV=pro
var config = require('config');
var name = config.get('person.name');