Ensuring .env files are set
Answered
Horned oak gall posted this in #help-forum
Horned oak gallOP
How do I ensure the prescence of .env files?
For example, when I run
The situation is worse when I
For example, when I run
npm run dev
, it simply start next.js but my app requires .env to be setThe situation is worse when I
npm run build
, no warnings no nothing and it just builds without .env file.Answered by LuisLl
You could check the .env file against a Zod schema to throw errors if the env vars aren’t defined or don’t match the validation. I believe that’s essentially what a package like this one does
https://github.com/t3-oss/t3-env
https://github.com/t3-oss/t3-env
1 Reply
You could check the .env file against a Zod schema to throw errors if the env vars aren’t defined or don’t match the validation. I believe that’s essentially what a package like this one does
https://github.com/t3-oss/t3-env
https://github.com/t3-oss/t3-env
Answer