I am trying to use the dotenv
NPM package and it is not working for me. I have a file config/config.js
with the following content:
I had the same problem and I tried 4 hours to find the fault. In my case, it was bizarre.
When I tried "node app.js", it worked. When I wanted a daemon to start it, it did not work.
How did I solve my problem? I replaced:
var dotenv = require('dotenv');
dotenv.load();
with:
var dotenv = require('dotenv').config({path: path.join(__dirname, '.env')})