Catalog npm
Back to packageRELEASE DETAILS

0.0.5

npm

12factor-dotenv

Include dotenv files in relative path tree, and parse with 12factor config

.env12factorconfigenvenvironmentexportexportsfilefilesloadparseprocessprocess.env
Published14 Apr 2015
Direct dependencies8
Transitive dependenciesNot calculated

README

Current package documentation

12factor-dotenv

npm version Build Status

NPM downloads

Automagically Load Dotenv Files (.env)

This module looks for .env files loads them with node-env-file and returns a 12factor-config

Features

  • relative to parent module
    • note: Parent module is one that requires 12factor-dotenv
  • loads .env files in an ascending relative path:
    • ./
    • ../
    • ../../

Install

npm install 12factor-dotenv --save

Config schema

This module uses 12factor-config to manage a config schema, for configuration support, Read More Here

Usage

in a single config file (obey 12factor and unify your config location), do something like:

// in ./app/lib/config.js

var config = require('12factor-dotenv');
var schema = {
	DEBUG: {
		env: 'DEBUG', // the environment export var to read
		type: 'boolean', // config var type (string, integer, boolean - maybe more see 12factor-config)
		default: false
	},
	PORT: {
		env: 'PORT',
		type: 'integer',
		default: 4000
	},
	MY_CUSTOM_VAR: {
		env: 'MY_LOCAL_ENVIRONMENT_EXPORT_VAR',
		type: 'string'
	},
	NODE_ENV: {
		env: 'NODE_ENV',
		type: 'string',
		default: 'development'
	}
};

var cfg = config(schema, { debug: true, env: { overwrite: true } });

## See https://www.npmjs.com/package/node-env-file#api for more details on `env` options

console.log('info: -- PORT is', cfg.PORT);
console.log('info: -- NODE_ENV is', cfg.NODE_ENV);

console.log('debug: -- ENV Debug is', process.env.DEBUG);
console.log('debug: -- ENV Port is', process.env.PORT);

console.log('info: < Configured.');

module.exports = exports = cfg;

now var cfg = require('./path/to/app/lib/config.js'); wherever you want your unified config - and keep .env(s) updated per environment.

Note!

This package also loads native process.env variables, when parsing .env files

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 8

Native requirements
8 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
12factor-config
Environment
{
  "local_name": "12factor-config",
  "alias": false,
  "peer_metadata": null
}
^1.0.0runtime
node-env-file
Environment
{
  "local_name": "node-env-file",
  "alias": false,
  "peer_metadata": null
}
^0.1.7runtime
chai
Environment
{
  "local_name": "chai",
  "alias": false,
  "peer_metadata": null
}
^2.2.0development
gulp
Environment
{
  "local_name": "gulp",
  "alias": false,
  "peer_metadata": null
}
^3.8.11development
gulp-mocha
Environment
{
  "local_name": "gulp-mocha",
  "alias": false,
  "peer_metadata": null
}
^2.0.1development
gulp-watch
Environment
{
  "local_name": "gulp-watch",
  "alias": false,
  "peer_metadata": null
}
^4.2.4development
lodash
Environment
{
  "local_name": "lodash",
  "alias": false,
  "peer_metadata": null
}
^3.6.0development
mocha
Environment
{
  "local_name": "mocha",
  "alias": false,
  "peer_metadata": null
}
^2.2.4development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "948e3ae3d3811ba62953f12ee2d9c5cfaceeebff",
  "tarball": "https://registry.npmjs.org/12factor-dotenv/-/12factor-dotenv-0.0.5.tgz",
  "integrity": "sha512-pBN1N2+ecY4WTr3U1gLqJNvKPnkXyo36wXhht5ftP0joC7BqxumUDnC8+JzlFlrOdCHxhmv8EC44CHR8cntmkg==",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQDqGgbEXEOecdwRMni1HhUJczXeUBJAyseA1vJOeTjO1gIgZI1D1y535OdKjyGiiHWxg8Pg4asgSgjwhRdWgsHuS7k="
    }
  ]
}

Repository

PENDING
electblake/node-12factor-dotenv

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:12 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:6575111b8a1e79955242588ab992a9452c8af5b40c03cfecc6be427f37d47f20

Other collected versions

0.1.616 Dec0.1.526 Jun0.1.426 Jun0.1.314 Apr0.1.214 Apr0.1.114 AprView all collected versions →