Try automatic resolution based on path and not load from the path
See original GitHub issueSo I have this monorepo setup where I want to have my .env.development and .env.production at the root level and reference the required variables in my service folders. Right now the path variable tries to load it directly from the file, without trying to find the file.
The issue with this approach is that if I hardcode what is my .env right now. I might have to change the path name in each service folder to production and then deploy. Which is cumbersome and feels wrong.
What I would like an option as readFrom
and given a path and the whole thing will run on that path instead of the current repo.
What do you guys think around this? Anybody faced same issue? I Might want to put in a PR on this but need suggestions from collaborators, also is there anyway we can currently do this that I might be missing?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12
I think I have a similar issue.
I run my serverless code inside of a subfolder of my larger project and the .env.${NODE_ENV} file is at the root. So in my server package I have this script:
Within my serverless.yml with the dotenv plugin I have:
But that doesn’t work. The system doesn’t load any of the env vars in that file.
If I hard code it like:
It works fine.
Is it possible to use environment variables in the setup of dotenv before it loads them from the file? I hope that makes a bit of sense. @SarasArya I hope this is the same as what you’re trying to accomplish.
@colynb Awesome, just tried it out, works great - thank you!