check-env
Makes sure that all required environment variables are set.
Install
$ npm install --save check-env
Usage
var checkEnv = ;;// => Throws an error if one of the variables aren't set.
CLI Usage
- Install as a project dependency as above
- Add to a lifecycle script such as
prestart
npm start
will bail out (exit(1)
) with a hard to miss error message if environment variables are not set
Example:
In package.json:
$ echo $MONGO_URL
# (nothing)
$ npm start
________________________________________
< Missing environment variable MONGO_URL >
----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
$ echo $?
1