env-cmd
env-cmd copied to clipboard
env.production file is merged into the file claimed by -f option
I've 2 files in the root folder of the project: .env.staging and .env.production In the .env.production file there is a variable not present in .env.staging
When I run env-cmd -f ./.env.staging node index.js
I can see the env variable present in the production file.
It looks like the final environment is calculated like that: {...env.staging, ...env.production}, merging .env.production into .env.staging
Is that correct?
Im facing this issue too
Same issue in my react app. In my case, this was due to react-scripts.
Files on the left have more priority than files on the right:
- npm start: .env.development.local, .env.local, .env.development, .env
- npm run build: .env.production.local, .env.local, .env.production, .env
- npm test: .env.test.local, .env.test, .env (note .env.local is missing) These variables will act as the defaults if the machine does not explicitly set them.
https://create-react-app.dev/docs/adding-custom-environment-variables