nodemon -v
: 1.18.5node -v
: 10.12.0nodemon -e js,graphql,env app/index.js
Nodemon should restart for changes in files like foo.env
as well as just .env
since both have the extension env
.
Note, just to clarify, I'm not looking for .env to control the behavior of nodemon, but I do want nodemon to restart my node server when .env changes because it has env vars that control the node server.
Nodemon will restart for changes to foo.env
but NOT for changes to .env
. This is a problem because a lot of tools like dotenv
use files like .env
without a prefix.
Use the command above on a dir with files like foo.env,.env
and observe.
If applicable, please append the --dump
flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.
Well, a temporary solution is to do:
// This works - use file local.env
require("dotenv").config({ path: "./local.env" });
// This does not - use file .env
require("dotenv").config();
However, .env
is still technically a file with extension env
so .env
should be watched by the -e
option of nodemon.
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3
I'm pretty sure there's an existing issue that raises something similar and explains why it can't be supported. If you can search, please do - it's late in the evening for me and I'm literally shooting to bed!
@remy I'm very appreciate the work you've done on nodemon, it work flawlessly and simplify the workflow of many people a lot.
I understand that most of the time files do have extensions and why many people want to filter by them to trigger some specific actions.
However, there are cases then one wants to watch for changes in any possible file. That may be handy to trigger file synchronisation across systems or to restart some systems as a whole.
There are so-called "dotfiles" which are a topic of the original issue: the files like ".gitignore", ".bash_profile", ".gitconfig", ".npmrc". I doubt they can be referred as files without the name but with a long extension. I think they are more like files without the extension which have a leading dot as a signal that they are special.
Another similar case is the files without extension at all. As an example, there are frequently used files like "Gemfile", "Rakefile", "Vagrantfile", "Dockerfile". Usually they contain the configuration and the file format is inferred from the file name itself, as a convention of tools which use that file. So they can contain ruby code like in case of "Rakefile", but they also can be of any possible format.
Currently if nodemon is provided with the --ext "."
argument it will trigger action on file having any extension. But it have to be an extension of some sort in place in order to trigger nodemon
action.
As far as I understand there is no option right now to run nodemon
from the command line and to have it trigger action on changes in files like ".gitignore" or "Rakefile".
I skimmed through the source code and I don't think I could provide a patch for that case soon, it seems as a rather complicated code, at least for me. Although I may try to come back to it later.
Remy, please take that case into the account as a valid issue for the fraction of people out there.
Thanks a lot for your magnificent work.
I've got a fix (and I'll add to the FAQ too):
You'll need to explicitly watch the hidden file _and_ tell nodemon the directory you want watch.
So your command looks more like this:
$ nodemon -e js,graphql,env -w .env -w . app/index.js
(assuming you want to watch the directory you kicked nodemon off from)
This replicated example should give you a sense of it working: https://github.com/remy/nodemon-test-cases/tree/master/1443
I'll also add this to the FAQ.
Most helpful comment
I've got a fix (and I'll add to the FAQ too):
You'll need to explicitly watch the hidden file _and_ tell nodemon the directory you want watch.
So your command looks more like this:
(assuming you want to watch the directory you kicked nodemon off from)
This replicated example should give you a sense of it working: https://github.com/remy/nodemon-test-cases/tree/master/1443
I'll also add this to the FAQ.