env-cmd icon indicating copy to clipboard operation
env-cmd copied to clipboard

env.production file is merged into the file claimed by -f option

Open zappyrent opened this issue 3 years ago • 2 comments

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?

zappyrent avatar Dec 09 '21 12:12 zappyrent

Im facing this issue too

namgold avatar Feb 18 '22 04:02 namgold

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

daichi-komatsu-asdf avatar May 13 '22 17:05 daichi-komatsu-asdf