Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Nodejs pickup changes rather than restarting the server every time?

Tags:

Is there a way for Nodejs to reflect the changes done in my files, rather than closing the node and running it again? I'm still in the development phase so I make a lot of changes, so what I do is I stop the server each time and run it again (with "node" command)

like image 829
AboulEinein Avatar asked Jun 03 '12 10:06

AboulEinein


People also ask

How do I start stop restarting a NodeJS server process?

If it's just running (not a daemon) then just use Ctrl-C . Where PID is replaced by the number in the output of ps . You could also use "killall -2 node", which has the same effect. Don't want/need to kill all node processes.

How do I restart Node server automatically?

Running non-Node code While Nodemon is running, we can manually restart our application. So instead of stopping and restarting Nodemon, we can just type rs and press enter, and Nodemon will restart the server or the running process for us.

Does Node require restart?

This is a quick tip for using nodemon to monitor your JavaScript files for any change. While doing development on any NodeJS application, whenever we make any change to some file we need to restart our Node server from the command prompt/terminal.

Which service can we download to automatically restart your Node app when we make changes?

nodemon is a command-line interface (CLI) utility developed by @rem that wraps your Node app, watches the file system, and automatically restarts the process.


1 Answers

I prefer to use https://github.com/remy/nodemon you can install it globally

npm install -g nodemon

and start your server by doing

nodemon app.js
like image 84
max li Avatar answered Oct 17 '22 08:10

max li