question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nodemon doesn't restart on file delete

See original GitHub issue
  • nodemon -v: 2.0.4
  • node -v: v14.2.0
  • Operating system/terminal environment: Linux Ubuntu 20.04
  • Using Docker? What image: N/A
  • Command you ran: N/A

Expected behaviour

According to this issue, Nodemon should restart when a file is deleted as it does when a file is added.

Actual behaviour

Nodemon doesn’t restart at all. I’m unsure if this feature was added at some point and then removed or if this is a problem with my setup but I’ve not been able to get Nodemon to restart on file deletion.

It works just fine when I edit or add files.

Is there a workaround for this?

Steps to reproduce

  1. Have Nodemon watch your project root:
  2. Delete a file
  3. Nodemon doesn’t restart

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
JGJPcommented, Oct 13, 2020

I personally think it’s fine for you to not fix it, but you keep bringing up the fact that nobody submitted a PR. Put in the perspective of this repo being 10 years old, I think 24 days is a really small window to give for a PR to be submitted. It’s also possible that people just decided to use something like onchange instead, or in combination (as I did)

1reaction
elitancommented, Aug 17, 2022

@remy Could this issue be solved by adding

watcher.on('unlink', filterAndRestart);

here: https://github.com/remy/nodemon/blob/main/lib/monitor/watch.js#L85

It seems to match what chokidar is using: https://github.com/paulmillr/chokidar/blob/master/lib/constants.js#L12

Read more comments on GitHub >

github_iconTop Results From Across the Web

Delete doesn't trigger a restart event in nodemon
Is deleting a file not supposed to trigger a restart event? How can I capture a file being deleted? I've tried the following:...
Read more >
nodemon not restarting Code Example
nodemon does not restart ... nodemon running but not restart the server on files changes ... Answers related to “nodemon not restarting”.
Read more >
Automatically restart Node.js apps with Nodemon
The essential tutorial for Nodemon, a utility for Node.js applications that monitors for changes and automatically restarts the server.
Read more >
Automatically Restart Node Apps on File Change with nodemon
Nodemon is an open-source utility package that keeps track of the changes made to your source code and restarts your project server ...
Read more >
Initializing a Node Project - Thinkster.io
That means every time we make a change to a file we have to restart our server. Thankfully, there's a tool called nodemon...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found