You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, it seems we're missing the ability to watch the env file. The command above will not restart the script when the env file changes.
--watch-path=.env doesn't help either. It does restart the script when the env file changes, however the env file is not loaded again, so the script only has access to the environment variables that were loaded when the command was first ran.
What is the feature you are proposing to solve the problem?
A flag to watch the env file e.g. --watch-env-file.
--watch-path=.env doesn't help either. It does restart the script when the env file changes, however the env file is not loaded again, so the script only has access to the environment variables that were loaded when the command was first ran.
I assume that the node process loads .env, then starts the actual application as a child process with the same --env-file flag. This should cause the child process to load the environment file upon start, however, the child process inherits the environment variables from the parent process, and inherited environment variables take precedence over variables read from .env, so you wouldn't see any changes to existing environment variables.
To test this hypothesis, could you check if you can see new variables in the child process when you add a new entry to .env while --watch is running?
Activity
MoLow commentedon Jul 23, 2024
this should probably be the default, without an extra flag
tniessen commentedon Jul 23, 2024
I assume that the
nodeprocess loads.env, then starts the actual application as a child process with the same--env-fileflag. This should cause the child process to load the environment file upon start, however, the child process inherits the environment variables from the parent process, and inherited environment variables take precedence over variables read from.env, so you wouldn't see any changes to existing environment variables.To test this hypothesis, could you check if you can see new variables in the child process when you add a new entry to
.envwhile--watchis running?OliverJAsh commentedon Jul 23, 2024
I just tested this and I can! You're right.
watch: reload changes in contents of --env-file
watch: reload changes in contents of --env-file