# Set environment variables in VSCode (Windows)

**URL:** <https://forum.codewithmosh.com/t/set-environment-variables-in-vscode-windows/8087>\
**Category:** Node\
**Created:** [October 22, 2021, 11:36am UTC](https://forum.codewithmosh.com/t/set-environment-variables-in-vscode-windows/8087 "2021-10-22T11:36:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maria.noaptes](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@maria.noaptes](https://forum.codewithmosh.com/u/maria.noaptes)\
**Post date:** [October 22, 2021, 11:36am UTC](https://forum.codewithmosh.com/t/set-environment-variables-in-vscode-windows/8087/1 "2021-10-22T11:36:16Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/7/76d45a69b6d3f357d2ce7a10874c565f88ba9dda.png)

Anyone on Windows that figured it out?

---

<div class="post-metadata">

**Author:** ![some\_random\_coder](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@some\_random\_coder](https://forum.codewithmosh.com/u/some_random_coder)\
**Post date:** [October 22, 2021, 2:13pm UTC](https://forum.codewithmosh.com/t/set-environment-variables-in-vscode-windows/8087/2 "2021-10-22T14:13:22Z")

</div>

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

```auto
echo $ENV:<VARNAME>

```

If you don’t see anything. Try this

```auto
$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

```auto
console.log(process.env.VARNAME)

```

If it somehow fails, then just use [dotenv pacakge](https://www.npmjs.com/package/dotenv) and store your env variables in `.env` file. It is more convenient to do so.
