nodemon is slow to restart the server
Asked Answered
S

1

13

I've recently reinstalled node package manager npm install nodemon -g which grabbed the latest build. But when I run nodemon server.js and I save changes to files, it's extremely slow to restart the server. It might take 10-30 seconds to detect file changes and when the restart process executes, it can take a few seconds to finish. I'm using nodemon 1.17.3. I don't have this problem on my other build (same PC and same local parent directory) that's using nodemon 1.14.8. Has anyone else experienced this?

Schnorr answered 6/4, 2018 at 3:2 Comment(5)
which OS? are you running it inside a docker container?Dressler
Windows 10. No docker, just localhost. Actually I rolled back to nodemon 1.14.8 and the problem went away.Schnorr
Also happening in Ubuntu 18.04LTS, nodemon 1.18.10Filmer
it is also happening to me as well..does anyone have a fix for this? [email protected] does not work for me. im on windows10 btwAlleras
I have the same issue with nodemon 2 (2.0.20) on windows 10 (10.0.19041.2364)Arrhenius
P
4

There can be several reasons for the slow server restart. Here are few things you can try

Exclude unnecessary files which doesnt require monitoring from nodemon Create a nodemon.config.js file and add the files you dont want nodemon to check while restarting the server ex:

{
  "ignore": [
    "node_modules",
    "public"
  ]
}

Or to check only the changed files you can specify nodemon which files to monitor while restarting the server by --watch flag

nodemon --watch src/user.model.js

You can also increase the amount of memory available to Node. If your server is slow due to memory limitations you can make the maximum amount of memory availbale (in megabites) by

nodemon --max-old-space-size=4096 app.js

I hope this helps.

Promotive answered 26/4, 2023 at 9:24 Comment(1)
One can check more about it at: nodemon.ioPromotive

© 2022 - 2024 — McMap. All rights reserved.