Open tyliggity opened 1 year ago
react-scripts loads the .env*
files via dotenv. so dotenv would need to notify the server when it detected env file changes, so the server can reload/restart.
I think this would be a feature request to https://github.com/motdotla/dotenv
but note: native env vars set from your shell (and not via dotenv from .env*
files) are always copied to the server process (in fact any process) and thus subsequent changes to them are not visible to it. it is impossible for a process to notice a change to env vars and a restart in this case is always needed
Describe the bug
Not sure if this is intended behavior but the live reload functionality behind
react-scripts start
does not acknowledge any changes to environment variables, at least those provided in a file. I tried with.env.development.local
. It's odd that the first time it runs the variables come through but then are never updated on subsequent reloads. I did not see any note of this in the docs and wasted probably 10 minutes before I just killed it and re-ran the same command to discover that was indeed the problem.Did you try recovering your dependencies?
I was using react-scripts
v5.0.1
Which terms did you search for in User Guide?
Environment variable docs: https://create-react-app.dev/docs/adding-custom-environment-variables/#adding-development-environment-variables-in-env
Environment
Steps to reproduce
(Write your steps here:)
.env.development.local
at repo root with a valuereact-scripts start
Expected behavior
Value should update
Actual behavior
Value does not update
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)