This is how can i run my server nodejs. I need to live reload my server when i make changes to the code in the front-end dev
"start": "node server.js"
Live Reload Frontend along with node server: To do this we are going to use livereload package. Fire up the terminal and run npm install livereload. Now inside your main server file In my case I have server. js Inside this file, we have to require livereload package and then reload(your_server_var); function.
Use nodemon for hot reloading Nodemon monitors for any changes in your source code and automatically restarts your application.
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.
first:
npm install -g nodemon
next add a script line to your package.json
"live": "nodemon server.js"
now when you npm live it'll live reload
for more details see https://github.com/remy/nodemon
update if live page reload is also needed
npm install -g livereload livereload . -w 1000 -d
for more details see https://github.com/napcs/node-livereload
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With