check-env

Makes sure that all required environment variables are set.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
check-env
1.3.05 years ago8 years agoMinified + gzip package size for check-env in KB

Readme

check-env
CircleCI
Makes sure that all required environment variables are set.

Install

```sh $ npm install --save check-env ```

Usage

```js var checkEnv = require('check-env'); checkEnv('REQUIREDVAR', 'OTHERVAR', 'ENVVAR'); // => Throws an error if one of the variables aren't set. ```

CLI Usage

  1. Install as a project dependency as above
  1. Add to a lifecycle script such as
`prestart`
  1. npm start will bail out (exit(1)) with a hard to miss error message if environment variables are not set

Example:

In package.json: ```json { "prestart": "check-env AWSKEY MONGOURL", "start": "node index.js" } ``` ``` $ echo $MONGOURL
(nothing)
$ npm start < Missing environment variable MONGO
URL > ----------------------------------------
\   ^__^
\  (oo)\_______
(__)\       )\/\
||----w |
||     ||
$ echo $? 1 ```