Set environment variables in VSCode (Windows)

Hello! I’m following the NodeJs tutorial and I’m in the Authentication and Authorization section (10- Storing Secrets in Environment Variables). I tried to set the environment variable like this:
set vidly_jwtPrivateKey=mySecureKey (I’m on Windows) , but I received the same error when running node index.js (FATAL ERROR: jwtPrivateKey is not defined.). I’m using the VSCode integrated terminal.

Anyone on Windows that figured it out?

First, I would name the env variable with all uppercase. Env variables aren’t case sensitive but all uppercase is a decent convention to follow.

Are you using PowerShell?
If so, I would make sure the env variable has been set using


If you don’t see anything. Try this

$ENV:<VARNAME> = 'secretkey'

Then, check it again.
Note that if you closed your PowerShell session, this env variable is gone.

Now, check your node app can read the env variable


If it somehow fails, then just use dotenv pacakge and store your env variables in .env file. It is more convenient to do so.