Reputation: 2967
So, I'm in the process of learning node, and am finding that for testing, I have to kill the running instance of node, then start it up again with the new application code for the server. So, I first execute my node server like this: node myapp.js
.
Then, I notice something isn't working right, or I want to add some new code to myapp.js. I go into Process Explorer (I'm running node on a Windows box), and kill the node.exe process, and then upload the new myapp.js file with the changes. Then I do node myapp.js
to start it again to test again.
There has got to be an easier way to do this. I typed in node --help
but there are too many flags listed to see if there is some kind of restart mechanism similar to apache on linux like: httpd -k restart
. Is there a kind of "graceful" restart with node?
Upvotes: 17
Views: 21923
Reputation: 8345
Check out nodemon. Install it using npm install nodemon
, after that simply use nodemon server.js
if server.js is the file you're working on.
Upvotes: 14