Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App is not updating when I save changes to app.js NodeJs

Tags:

node.js

I'm building my first NodeJs app, and I was hoping that the browser would update whenever I hit Control+S on my app.js file. For example, initially I have it outputting Hello world, then I do node app.js, visit http://localhost:3000 in my browser. If I go back to editing app.js and update it to be Hello world2, I have to cancel node via Control+C, then node app.js to see my updates. Not even doing F5 in my browser will get the latest changes.

like image 975
Ian Davis Avatar asked Oct 21 '25 11:10

Ian Davis


1 Answers

You can use Nodemon to auto-restart your server when files are changed

Install:

npm install -g nodemon

Run:

nodemon ./server.js localhost 3000
like image 84
Will Richardson Avatar answered Oct 23 '25 02:10

Will Richardson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!