Nodemon stuck at "restarting due to changes..." and won't restart the server
Solution 1
I am using window 10, and I faced this issue after I accidentally removed my %PATH% variable. Try adding these three paths if it is the case:
C:\Windows; C:\Windows\system32; C:\Windows\System32\Wbem;
Solution 2
For those who still do not have an answer, I reinstall an older version and it works
like "npm i -g [email protected]"
Solution 3
Add the below path in the environment variable. It will solve your problem. %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\wbem;
Solution 4
Use below two commands:
npm install supervisor -g
supervisor src/index.js
Solution 5
I was using windows 10, and I faced the same issue. I used the supervisor instead of nodemon and it started working fine for me.
Run the below command :
npm install supervisor
and in package.json add these below lines of code in the scripts key
"scripts": {"start": "supervisor app.js"}
Related videos on Youtube
Christopher Francisco
Updated on June 04, 2022Comments
-
Christopher Francisco almost 2 years
I have a pretty basic nodemon configuration. I'm fixing this legacy node 7 project that I inherited and trying to make the development process a little bit painful. First thing first, a proper restart-and-transpile process (since it's built using ES6 modules syntax).
This is my folder structure:
- src |- index.js - dist |- index.js - index.js - nodemon.js
I run nodemon as
"start:dev": "nodemon index.js"
Here's it's content:
// index.js if (process.env.NODE_ENV === 'production') { require('./dist/index.js'); } else { require('babel-register')({}); require('babel-polyfill'); require('./src/index.js'); }
The idea is that the code is transpiled on runtime, so that I don't have to stop server, re-transpile, start server manually, as I have been doing before.
Last but not least, nodemon config
// nodemon.js { "restartable": "rs", "ignore": [ ".git", "node_modules/**/node_modules" ], "verbose": true, "watch": [ "src" ], "env": { "NODE_ENV": "development" }, "ext": "js json" }
I took this setup from MERN, and I think it should work. However, when I made a change and save, it goes:
[nodemon] files triggering change check: src/index.js [nodemon] matched rule: /Users/me/project/path/src/**/* [nodemon] changes after filters (before/after): 1/1 [nodemon] restarting due to changes... [nodemon] src/index.js (stuck here. it never restarts)
I've been checking the code, and the only thing that I'm unfamiliar with, that maybe be causing it I can think of would be a
child_process.execFileSync()
call, that will call a java tool; and a connection pool withmysql.createPool()
(mysql
package).Tried both in Node 7.5 and Node 8.9. Any idea of what could be wrong?
-
Jeremy Caney almost 4 yearsIt'd be valuable to add an explanation of what
node-supervisor
is and why it solves this problem.