James
James

Reputation: 115

Is it possible to use one .env file for a single repository?

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

Answers (1)

Lin Du
Lin Du

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

Related Questions