Make Express server refresh automatically



I am an experienced server side developer and JS developer, but new to node and express.

Why must I run bin/www again in order to see changes? isnt node like PHP? allowing to change the code while running?



Hi, Avi.

What do you mean by running bin/www again?
If you run the file (the .html files) itself I believe it will run Apache and act like a simple ftp server / static server (PHP works easily like that).

But when you’re using Node.js, you need to run the initial app.js(or whatever that file is called for you) file, in which you may set using Express the folder bin/www static. Static folders set does not need you to re-run the node program. But if you change the app.js file itself I believe you’ll need to re-run it.

-Joe Tannoury


Hello and thanks.
According to this tutorial, when I want to run the node server i need to run in the shell: bin/www so the node server will run.

If I do so, when I change the index.js for exanple, I dont see the changes unless i run in the shell bin/www again



Oh I get it now. Running “bin/www” runs “bin/www/index.js” of course.

Run index.js in debugger mode, that way you’ll see the changes live after saving the file.

Follow the tutorial page till the end on how to set up a “CREATING A RUN CONFIGURATION”. Don’t forget to set the debugging to true.

-Joe Tannoury


So, I have created the run configuration, its event entering to debug.
But the changes in the file index.js or users.js are not appearing till I restart.


Hi Avi,

Right. Node will not automatically restart the server when you change code. However, there are utilities that reload the server on file changes, like etc.



@mutahhir, So what JoeTann wrote is not correct? Wasnt what he says suppose to show changes in the browser?


@Avi only the static files automatically changes, not the node app itself. My mistake.


I see, what is the shell command to reload the files into node? thanks


There is no shell command but you can use to make it auto restart.


Like everyone else is saying Nodemon is my favorite tool out there for accomplishing this exact thing. Easy to use and has some good features(including support for coffeescript)