nodemon "restarting due to changes..." repeatedly displays in VSCode and slows down every restarting process

Viewed 6217

I use nodemon version 1.18.9 (Latest version as of today).

I use Visual Studio Code (VSCode). I open a terminal and execute nodemon dev-server.js but it displays this repeatedly

restarting due to changes...

as follows

nodemon-restarting

and after a few seconds it will complete its restarting process.

I use Windows 10.

Any suggestions?

4 Answers

package.json

   {
      "scripts": {
        "nodemon": "nodemon dev-server.js"
      },
    }

start nodemon by npm

$ npm run nodemon
save dev-server.js file, nodemon will restart twice

start nodemon direct

$ nodemon dev-server.js
save dev-server.js file, nodemon is all right

osx 10.11.3
nodemon 1.9.2

=============UPDATED ANSWER FROM COMMENTS======================

updating answer from comments as logic from comments worked for this problem.

try adding delay for some time. let me know if it works. nodemon lib/dev-server.js --delay 1 ..

whatever your directory is.

I guess you have to change the settings on the VSCode, go to File->Auto Save(unmark the option). After that the project will restart only when you use ctrl+s on the specific path.


Edit: I did some tests on my computer and I reproduced what you trying to mean, probably you are trying to use diferent extensions that nodemon does not support. Take a look on this part of the documentation:

Specifying extension watch list By default, nodemon looks for files with the .js, .mjs, .coffee, .litcoffee, and .json extensions. If you use the --exec option and monitor app.py nodemon will monitor files with the extension of .py. However, you can specify your own list with the -e (or --ext) switch like so:

nodemon -e js,jade Now nodemon will restart on any changes to files in the directory (or subdirectories) with the extensions .js, .jade.

try to run nodemon -e ts,json(all extensions that you want to be listener) dev-server.js. When I removed the extension I got the same issue of you.

  1. Try to build your application without using nodemon
  2. Correct the errors, which may be the result of tslint being unable to fix something and generating a syntax error
  3. Restart your application with nodemon

please set Windows Environment Path

  1. Right Click PC/My Computer
  2. Properties
  3. Environment
  4. Path --> Edit --> New
  5. Paste:- C:\Windows\System32

ok then restart VSCode

Related