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.gitand copyset_env.shto the same directory as yourpackage.jsonfile. - Add the list of environment variables to APIServices array in the
set_env.shfile. 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.shfile will be generated. - To export local environment variables add
source exports.shto your dev script in yourpackage.jsonfile.
"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\"",
}