remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.31k stars 1.73k forks source link

Stuck at: "[nodemon] restarting due to changes..." #2060

Closed rmjuarez12 closed 1 year ago

rmjuarez12 commented 2 years ago

Expected behaviour

When I make a change to a file, the server automatically restarts

Actual behaviour

It gets stuck with the message "[nodemon] restarting due to changes..."

Steps to reproduce

Things I have tried

Comments

It is worth noting that I have tried downgrading to lower versions of nodemon, in order to troubleshoot if it was the version, but that did not helped. This started happened randomly, as it was working perfectly fine a week ago. What is weird is that, the same app I am working on, nodemon works really well on my laptop, but not on my PC. I do have everything up to date(npm, node, Windows, VSCode, and even bash), but that still does not solve my issue.

dever23b commented 2 years ago

Just putting this out there because it's caught me in the past. Is there any chance you have attached a debugger and it's paused execution?

Sometimes I don't realize the debugger is attached. If it is attached and paused, it effectively hangs everything up. In my case, either Continue-ing through the rest of the code or simply reconnecting the debugger allows the program to continue and eventually exit, thereby allowing restart.

rmjuarez12 commented 2 years ago

Hmm I haven't really done anything out of the ordinary to my setup. It just started happening randomly one day. The weird part is that, on my laptop, I have the same codebase with the same setup(same Node version and same nodemon version), and in there it works as expected. My laptop is also using Windows 10 with the latest Window updates. --verbose, but that was after the fact, so that was not it. I have tried everything I've found online, but nothing seems to work. It is frustrating as I am so used to having nodemon restart every file change lol

With that said, how can I find out if I've attached a debugger? Maybe I did it accidentally.

dever23b commented 2 years ago

We may very well be experiencing completely different issues then, unfortunately.

You can configure VS Code (via a launch.json file) to debug your Node application. In my case, I have mine setup to automatically re-attach to Node on the project I'm working on. I enable it early on and then, as I'm working and testing, sometimes I forget it's still attached when I break on something and take some time to tweak the code. I'm not sure if it's a user preference but, for me, when the debugger is attached, the bottom bar of VS Code changes from its normal sky blue background to orange.

More information on VS Code debugging

rmjuarez12 commented 2 years ago

Ah gotcha. I do appreciate you explaining that to me. Then it is not the same issue with me. I will try and keep digging around and see if I can ever fix it lol someone did tell me it might be a Windows permission issue, so I will try to check and experiment with that. I initially thought it was maybe on that project only, but it happens on all my other projects as well, so it has something to do with my Windows setup or something. What make me wonder is why anything else(like Flutter or even React) works normally without any issues. This has me honestly pulling my hair lol

Arahikt commented 2 years ago

I do have the same issue. I tried different things on SO, but none of them worked. It keeps printing "[nodemon] restarting due to changes..." but never starts node back again and never changes anything in the postman. I did try adding localhost:5000 to my anti-virus safe paths, but that didn't help either.

rmjuarez12 commented 2 years ago

Did it happened to you randomly as well? For me, nodemon was working as expected and all good, but one day, it just decided to stop working. I just don't know what else to do lol

Arahikt commented 2 years ago

No, actually, I installed it not very long time ago, but it had the issue since then.

Arahikt commented 2 years ago

@rmjuarez12 I've just found out how to get it to function correctly. Add "nodemon": "nodemon app.js" to your "scripts" . Then run "npm run nodemon". This is the only way I could make it work properly. Try it out.

rmjuarez12 commented 2 years ago

@Arahikt Thanks for the suggestion. I am already using it in a script, so sadly, that is not a fix for me. I do appreciate your response, though!

Lipemenezes commented 2 years ago

I'm having the exact same issue. It started a few days ago out of nowhere.

My partial fix was to remove --inspect and --trace-warnings from my script.

More details on my problem: Ubuntu 20.04.5 LTS node -v v16.17.0 nodemon -v 2.0.19

package.json script: "dev": "nodemon --inspect --trace-warnings ./main/index.js"

Starting server:

[0] [nodemon] 2.0.19
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching path(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node --trace-warnings ./main/index.js`

Whenever I update any file:

[0] [nodemon] restarting due to changes...
[0] [nodemon] starting `node --trace-warnings ./main/index.js`

But the codebase isn't affected. For my changes to be reflected, I need to finish the app and start it again manually.

Also, if I run nodemon with the --inspect flag on, I get this message after I save any file:

[0] [nodemon] restarting due to changes...
[0] [nodemon] starting `node --inspect --trace-warnings ./main/index.js`
[0] Starting inspector on 127.0.0.1:9229 failed: address already in use

I've already disabled and removed debug configs from my VSCode to isolate the problem and it still happened.

remy commented 2 years ago

Sometimes worth introducing an environment variable set to DEBUG=nodemon,nodemon:* and it'll spit out everything going on which might help you see why it's gotten stuck.

rmjuarez12 commented 2 years ago

@remy Thanks for your suggestion. I tried running the script with the env you mentioned, but it gets stuck at:

nodemon bus emit: restart +20s
nodemon:run terminating process group by force: 10528 +20s

You can see it in the image below. I am all out of ideas lol it has been a bit frustrating trying to find a solution. I know this might be a Windows issue, but what I am very confused about is why did it happened randomly. It has been working perfectly fine for months with no issues, but then it just suddenly did not wanted to restart the server and got stuck.

Desktop Screenshot 2022 09 16 - 15 00 23 46

vaudy commented 2 years ago

Hey I just had the same issue as you but after digging in the doc, I added --watch and solve the issue, hope it solve your's

--exec 'ts-node ./src/index.ts'

rmjuarez12 commented 2 years ago

@vaudy Thank you so much for your response. Sadly, that still did not fixed my issue. It still gets stuck at "restarting due to changes...". I may just need to let it go and maybe find another solution. I have tried everything I have found online, and it still gets stuck in there. Mind you, I have updated EVERYTHING! Windows, Node, NPM, nodemon, and still nothing. I am really all out of ideas lol

Just one more thing to note. I have tried using different terminals. I have used bash, powershell, and even CMD prompt, and they all have the same issue, so it is not just on my VSCode terminal.

Also, a side note, I installed Flutter on my PC. I am not sure if that is a factor, but it is worth mentioning. So basically, after I installed Flutter, and the necessary dependencies, such as Android Studio, Android SDK Command Line Tools, and Android SKD build tools. Again, it might be totally relevant, but I kinda feel like this might be the only thing that could have made a critical change somewhere that made nodemon stop working properly.

github-actions[bot] commented 2 years ago

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

rmjuarez12 commented 2 years ago

It has not been fixed yet, I still have this issue!

github-actions[bot] commented 2 years ago

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

matias-sanchez1998 commented 1 year ago

Encontraron alguna solución?

matias-sanchez1998 commented 1 year ago

Hello, did you find any solution?

rmjuarez12 commented 1 year ago

Nope, sadly, no solution. I just gave up and just restarted the server myself whenever I made changes.

rmjuarez12 commented 1 year ago

Ok, finally, after just having the thought roam around my head for a while, I decided to just reinstall Windows 10 on my PC, and that fixed the issue. Guess somewhere along the lines, something might have messed with my Windows files.

So in short, if all fixes available to you fail, just reinstall Windows.

github-actions[bot] commented 1 year ago

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

tomastan commented 1 year ago

Having the same with Linux Ubuntu 22.10. So it may be not related to Windows. Nodemon version 2.0.20

fredrikfolke commented 1 year ago

Same issue here.

[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] starting node ./app/build/start.js
[nodemon] restarting due to changes...
[nodemon] starting node ./app/build/start.js

After many restarts the app says Error: listen EADDRINUSE: address already in use :::443

Then this error appears [nodemon] app crashed - waiting for file changes before starting....

After the crash the process needs to be manually killed and only then the app can restart.

Ubuntu 22.04.1 LTS Node v16

github-actions[bot] commented 1 year ago

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

hewentaowx commented 1 year ago

I first used the powershell in vscode. I replaced the terminal with bash, and then it was OK

github-actions[bot] commented 1 year ago

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

github-actions[bot] commented 1 year ago

Automatically closing this issue due to lack of activity

nirwannursabda commented 10 months ago

for future reference my solution so far on windows

add path to user variables and system variables C:\Windows C:\Windows\System32 %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\wbem;

and then restart computer

rmjuarez12 commented 10 months ago

for future reference my solution so far on windows

add path to user variables and system variables C:\Windows C:\Windows\System32 %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\wbem;

and then restart computer

This is in fact the solution in most cases. However, if this solution does not work, you have to re-install Windows. With Windows 10/11, you can reinstall Windows without formatting your HDD/SSD. So, if the solution above does not work, reinstall Windows. That is what fixed it for me.

techsin commented 6 months ago

use concurrently instead of npm-run-all