Terminal Environment variables not being respected

I've got 3 environment variables that I set in Settings->Terminal. 

HTTPS=true;SSL_CRT_FILE="D:\dev\localhost.crt";SSL_KEY_FILE="D:\dev\localhost.key"

However, when I run "npm start", my variables are ignored. I have to pass them into the command line to make them work:

HTTPS=true SSL_CRT_FILE="D:\dev\localhost.crt" SSL_KEY_FILE="D:\dev\localhost.key" npm start

This started with WebStorm 2021.2.1. I'm on Windows 10. My default terminal is Git Bash.

9 comments
Comment actions Permalink

Can't reproduce

What is a result of running 

echo $SSL_KEY_FILE

in the build-in terminal? Please share a screnshot of the File | Settings | Tools | Terminal page

0
Comment actions Permalink

The result of the echo is: D:\dev\localhost.key.

Again though, when I run just "npm start", I get errors that my page isn't secure. But when I run the whole line:

HTTPS=true SSL_CRT_FILE="D:\dev\localhost.crt" SSL_KEY_FILE="D:\dev\localhost.key" npm start

My page loads as expected.

Screenshot:

0
Comment actions Permalink

>The result of the echo is: D:\dev\localhost.key

so the variable is resolved, isn't it?

0
Comment actions Permalink

I see where you're going and sure, the echo worked. But then why when I run "npm start", it doesn't pull from the environment variables? Why would I have to pass them in on the command line?

0
Comment actions Permalink

No idea... I've just checked that if I create a code like

console.log(process.env.FOO);

add npm script that runs this code, set FOO in terminal preferences and then run this script in terminal, it works as expected:

0
Comment actions Permalink

I did the same thing. I added:

console.log(process.env.SSL_CRT_FILE);

And all I got was an "undefined".

Just to add, this is inside of a React project.

0
Comment actions Permalink

What does `printenv SSL_CRT_FILE` say in the built-in terminal? What's your Git Bash version?

0
Comment actions Permalink

Thanks for the information. So, `SSL_CRT_FILE` environment variable is passed to `printenv` process, but is not passed to `npm start`. What's the output if you run `node KevisTest.js` directly in the built-in terminal?

0

Please sign in to leave a comment.