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

Package detail

barricade

saidM4MIT1.0.3

Load environment variables from env.yml file (works for dev, test & production)

environment, variable, env, variable, config, variable, node, env, dotenv, figaro, secrets, env variable, barricade

readme

Barricade

Build Status NPM Downloads license XO code style

NPM

Barricade is a small library that allows you to setup environment variable from a single env.yml file. It parses the YAML file and loads all of the configuration values into the process.env object.

It has built-in support for multiple NODE_ENV.

Installation

npm install --save barricade

Usage

Add the following line at the top of your application JS file:

 require('barricade')

The library expects a YAML file (env.yml) at the root of your application. Given the following YAML file:

# env.yml

APP_SECRET: hello_world
STRIPE_SECRET_KEY: secret_key_for_both_development_and_test

production:
    STRIPE_SECRET_KEY: secret_key_used_only_in_production
`

You can then start your application and access those values from the process.env object. Example:

// index.js

require('barricade')

console.log(process.env.APP_SECRET) // hello_world
console.log(process.env.STRIPE_SECRET_KEY) // secret_key_for_both_development_and_test

// Switch the Node environment to production
process.env.NODE_ENV = 'production'

console.log(process.env.STRIPE_SECRET_KEY) // secret_key_used_only_in_production

Licence

MIT