Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

envc

vesln355MIT2.5.0

Loads environment variables from dotenv files

readme

envc Build Status NPM version NPM downloads LICENSE

Loads environment variables from .env files.

Inspired by dotenv by Brandon Keepers.

Usage

// `options` are optional
var env = require('envc')(options);

Options:

  • path: Path to the .env file [optional, default: cwd]
  • name: Name of the .env file [optional, default: '.env']
  • nodeenv: NODE_ENV [optional, default: process.env.NODE_ENV]
  • booleans: enable boolean parsing, [optional, default: false]
  • numbers: enable number parsing, [optional, default: false]
  • readonly: load and parse .env file only (i.e. does not modify process.env), [optional, default: false]
  • overwrite: allow process.env to overwrite file values [optional, default: false]

Inheritance

envc will try to load:

  • {name}
  • {name}.{NODE_ENV}
  • {name}.local

Interpolation

URL_HOST="vesln.com"
URL_PATH="index"
URL_FULL="http://${URL_HOST}/${URL_PATH}"
DOCKER_SERVICE=$(boot2docker ip):11211 # works on node 0.12+

Installation

npm install envc

License

MIT

changelog

2.4.1 / 2015-10-26

  • Merge pull request #15 from CacheControl/fix-invalid-line
  • fix invalid line error reporting

2.4.0 / 2015-08-31

  • Handle basic shell command execution

2.3.2 / 2015-08-13

  • Remove carriage returns

2.3.1 / 2015-07-30

  • Merge pull request #11 from vesln/bug/ips
  • code + tests for not parsing ips as numbers

2.3.0 / 2015-07-20

  • Merge pull request #10 from vesln/feature/overwrite
  • overwrite test for default behavior
  • option: overwrite allows process.env to take overwrite file values

2.2.0 / 2015-04-03

  • Handle undefined values
  • Use default node environment if none

2.1.0 / 2015-02-04

  • Merge pull request #6 from wilmoore/readonly-option
  • support readonly option

2.0.1 / 2015-01-26

  • Merge pull request #5 from wilmoore/ignore-empty-lines
  • Correct empty line parsing (fixes #4)
  • readme: fix interpolation mis-representation

2.0.0 / 2014-11-14

  • Merge pull request #1 from wilmoore/return-only-parsed
  • return only parsed keys/values

2.0.0-alpha1 / 2014-09-15

  • Add support for inheritance
  • Introduce Loader
  • Initial parser

1.1.1 / 2014-03-23

  • Improve error handling

1.1.0 / 2014-03-23

  • Do not throw when the .env file cannot be found

1.0.0 / 2014-01-25

  • Initial implementation