Webstorm load .env file Run/Debug/Test configuration
May 6, 2021
When testing or debugging one might want to add environment variables for that specific environment.
Webstorm accommodates this via its config.
You will need
npm install dotenv
- Open edit configurations
3. In the Node Options:
enter -r dotenv/config
. This will provide the node option with -r dotenv/config which will load env file into your process.env.
4. In the Environment Variables:
enter DOTENV_CONFIG_PATH=./<your_env_dir>
this tells dotenv package where to look for your environment variables.
For Reference mine looks like this
Thanks for coming to my Ted talk.