问题
I use nodemon as a dev-dependency in node. Suddenly, in CLI it shows:
[nodemon] restarting due to changes...
when I am changing the code. Then I have globally installed nodemon but it still isn't working. It is not working on any project-- not a single project.
Any help? I have attached a screenshot of my CLI:
回答1:
It's probably because starting updates a file that the server is watching, therefore triggering a restart event in an infinite loop.
Nodemon supports the --watch
and --ignore
commands. Play around with them to only watch a certain set of files. Example:
# Only watch the "server" directory
nodemon --watch server server/main.js
# Watch both the "server" and "client" directory
nodemon --watch server --watch client server/main.js
# Watch the "server" directory, but ignore "server/logs"
nodemon --watch server --ignore server/logs server/main.js
来源:https://stackoverflow.com/questions/61032383/nodemon-is-not-working-nodemon-restarting-due-to-changes