Closed wathika-eng closed 5 months ago
Hello @wathika-eng , I think the problem is the way you're running the script and the concept of "current working directory"
Given this little script that checks your cwd
script:
And this file Structure:
Notice the difference in output when I call the script from outside the dir
directory with path dir/script.js
and when I call it from inside the dir
directory with script.js
:
So even when you're calling routes/router.js
, your current working directory is still the project's root, so you don't need to specify the path to your .env
file.
Worked after deleting the path I had specified
Tried some solutions from closed issues e.g https://github.com/motdotla/dotenv/issues/546 and https://stackoverflow.com/questions/44915758/node-process-env-variable-name-returning-undefined but none seems to be working