Should I have multiple .env files? #746
Replies: 1 comment
-
Hi @poojakumari19, Can you share how you are switching between your This is a pretty old answer on the FAQ and we are starting to modify it slightly as we have recently taken a strong opinion on how to handle environment variables in production, staging, ci, etc: ℹ️ A note from Mot: Until recently, we did not have an opinion on how and where to store your secrets in production. We now strongly recommend generating a .env.vault file. It's the best way to prevent your secrets from being scattered across multiple servers and cloud providers – protecting you from breaches like the CircleCI breach. Also it unlocks interoperability WITHOUT native third-party integrations. Third-party integrations are increasingly risky to our industry. They may be the 'du jour' of today, but we imagine a better future. This is a big step for dotenv as in the past it has been focused just on the development environment. I would right now lean toward recommending you use a |
Beta Was this translation helpful? Give feedback.
-
We can have multiple .env files for development, production and also if there are multiple different modules in the project then can have specific configuration particular module in their respective development, production file.
And then in package.json file of for running the node js server we can have multiple script define there with the NODE_ENV defined such as - "start-production": "set NODE_ENV=production&&ts-node-dev index.ts",
Note- As in F&Q section of dotenv package it mentioned that .
No. We strongly recommend against having a "main" .env file and an "environment" .env file like .env.test. Your config should vary between deploys, and you should not be sharing values between environments.---This line is making confused.
Beta Was this translation helpful? Give feedback.
All reactions