A command line tool for Node.js to export a list of environment key value pairs to an export.sh file; which can then be used as a part of a development script to set local environment variables.
- clone this repo
git clone https://github.com/momotofu/node-env-variable-cli.git
and copyset_env.sh
to the same directory as yourpackage.json
file. - Add the list of environment variables to APIServices array in the
set_env.sh
file. See file comments for an example and further instructions. - To populate the script you'll use to set local env variables run
source set_env.sh
. This command will run the user through each environment variable key and prompt for the associated value. When user has entered all the required values, anexports.sh
file will be generated. - To export local environment variables add
source exports.sh
to your dev script in yourpackage.json
file.
"scripts": {
"dev": "source exports.sh; concurrently --kill-others \"webpack-dev-server --mode=development --progress --colors --port 2992\" \"NODE_ENV=development nodemon ./src/backend/app.js\"",
}