0

So I have a basic express app and I'm trying to have it refresh with file changes , I've tried reload, supervisor, nodemon and browser-refresh with no luck , any tips.

Here's my app.js

const path = require('path')
const express = require('express')

let app = express()
let port = process.env.PORT || 3000

app.get('/', function (req, res) {
res.sendFile(path.resolve('index.html'))
})

app.listen(port,function(){
console.log("magic happens on port " + port)
})

and then I run

nodemon or supervisor or browser-refresh app.js
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • I also propably should have mentioned that this sever is supposed to render a react-app compiled by webpack. so after running ```webpack``` The browser doesn't refresh, well It doesn't refresh with changes to ```index.html``` either – JetB Coder Jul 20 '17 at 16:59
  • There are a number of webpack plugins to hot-reload the page on code change. If all you want to do is serve static files, you can use a plugin like [webpack-livereload-plugin](https://www.npmjs.com/package/webpack-livereload-plugin). If you want to integrate this hot-reloading in your express app, I would recommend [webpack-hot-middleware](https://www.npmjs.com/package/webpack-hot-middleware) – yazgazan Jul 20 '17 at 17:16
  • Thanks @yazgazan, I'll try that out – JetB Coder Jul 20 '17 at 18:16

0 Answers0