javascriptnode.jsnpmnodemon

NodeJS - nodemon not restarting my server


I installed NodeJS (4.4.5) and then proceed to install nodemon (1.9.2) as well, I follow all the instrucctions of instalation (npm install -g nodemon)

I created a new folder, inside I have my server.js with some basic code:

var http = require('http');

http.createServer(function (request, response){
    response.writeHead( 200, {'Content-Type': 'text/plain'} );
    response.write("Hello world");
    response.end();
}).listen(3000, 'localhost');

console.log('http://localhost:3000');

So when I run in my console "nodemon server.js" I get this:

[nodemon] 1.9.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
http://localhost:3000

(Which means that is running fine)

But when I make some changes in my server.js, It doesn't restart the server

What could be the issue?


Solution

  • 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