I have a node project, with index.js and .env in the same folder.
index.js looks like this:
console.log(require("dotenv").config())
console.log(process.env.TIMES)
.env looks like this:
TIMES=2
In this folder in powershell I run node index.js. I have already installed dotenv and such.
I get the following output:
{ parsed: {} }
undefined
I am unable to source my environment variables. What am I doing wrong?
You have to define require("dotenv").config() outside console.log
require("dotenv").config()
console.log(process.env.TIMES)