As a Windows user, I had problems in the past with exporting / setting environment variables for node to use.
I ended up using the dotenv NPM package since you can be sure it correctly loads the environment variables regardless of what system you are developing on.
Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env.
First, install and save it:
npm i dotenv
Create a file in the root of your project called .env
PORT=5000
You can set any number of variables using simple X=Y syntax.
Then, somewhere in your code:
require('dotenv').config();
// my main application code
With the above example, you now have access to process.env.PORT which will equal 5000 (value set from the .env file)
Note: Avoid storing .env in your version control by adding a .gitignore rule:
node_modules/
# Other ignore rules...
# Add this line
.env
Good luck!