NodeJS - nodemon not restarting my server
I just hit what seemed to be the same issue where I would make changes to my code and save them but nodemon wouldn't restart my server. The only way I could update was via 'rs' in the console. I ended here looking for a solution but then decided to just re-install nodemon as there was no good explanation for why it wasn't working:
npm uninstall nodemon
npm install nodemon
After reinstalling the automatic restart on code change worked.
I had the same issue on nodemon 1.9.2 : 0 files were watched by nodemon
(try verbose mode nodemon server.js -V
to get more information)
After some research, this issue was due to my root directory name : My root directory was named "mysite.git" thus nodemon was watching 0 file. I had renamed my root directory without the dot and nodemon now works as expected.
Remove all special characters from your root directory and nodemon should work as expected.
In some networked environments (such as a container running nodemon reading across a mounted drive), you will need to use the legacyWatch: true which enabled Chokidar's polling.
Via the CLI, use either --legacy-watch or -L for short:
nodemon -L
You can try running like this nodemon -L yourapp.js
, something like that:
"scripts": {
"start": "node index.js",
"dev": "nodemon -L index.js "
}
And run command:
npm run dev
This worked for me!