I want to work with environment variables. Unfortunately, I am an inexperienced developer and decided very late to implement such a solution in my project.
I'm trying to inject environment variables, located in .env file, to all JS files (not all of them using environment variables, but I thought it would be faster and easier). Currently, I'm using dotenv package but it is obviously working in one file at once.
Should I use dotenv the standard way? Maybe there's a vulnerability I don't know of and that's why it is very unpopular to use environment variables this way.
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config();
}