Reputation: 115
The project I am working on has multiple node-modules within subfolders, and how I am structuring it now it seems dotenv is unable to locate the .env
file in the root. This making the process.env
variables undefined
. Is there anywhere way I can make the environment variables accessible from all directories?
I have tried putting require('dotenv').config();
at the top of the files, and even tried adding a script to run it in jest.config at the root. All results in undefined
.
Upvotes: 0
Views: 620
Reputation: 102517
I am not very clearly what did you want to do. But you can use dotenv#path option to specify a path for .env
file you want to load.
Upvotes: 1