Reputation: 1441
I am trying to set a environment variable in Windows 10 command line with this command:
set NODE_ENV=production
When I use echo %NODE_ENV%
, it is working just fine.
But when I use process.env.NODE_ENV
inside VS Code, it is still undefined.
I tried to set this variable inside VS Code command line, but doesn´t work either. This doesn´t work with any environment variable (PORT, etc.)
I also tried to use app.get("env")
which is set to development by default. When I set NODE_ENV
to something else, it doesn´t work as well.
Do you have any idea, where is the problem? Do I have to configure something somewhere? Thanks for your advice.
Upvotes: 0
Views: 3195
Reputation: 1086
You need to add require('dotenv').config()
in your application
https://www.npmjs.com/package/dotenv#usage
Upvotes: 1
Reputation: 121
The first thing that pops to my mind is to restart the server. I've forgot about it numerous of times.
Upvotes: 1