Reputation: 731
So I'm using express to make a server:
import express from 'express';
const app = express();
const PORT = 3000;
app.use(express.static('public'));
app.get('/', (req, res) => {
res.sendFile('index.html');
});
app.listen(PORT, () => console.log(`Server running on http://localhost:${PORT}`));
The server works successfully, however I need it to live-reload when I update the HTML file
Can anyone help?
Upvotes: 2
Views: 3668
Reputation: 133
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
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
Upvotes: 4