I'm using neutrino node.js preset with hot module replacement enabled, here's what I have in index.js:
import fastify from 'fastify'
import router from './router'
const ft = fastify()
ft.register(router)
// enable hot module replacement
if (module.hot) {
module.hot.accept()
}
// listen
ft.listen(3000, 'localhost', (err) => {
if (err) throw err
console.log(`server listening on ${ft.server.address().port}`)
})
When I edit a file, I would got this:
I'm wondering if it is possible to use hot module replacement like this? Anyone have experience?
Thank you.

When using HMR with Node.js, it is a little trickier than with web projects since reloading the top-level file would mean needing to restart the process.
If you take note from the Neutrino docs on HMR in Node.js, you'll see that HMR isn't performed on the top-level
index.jsfile, but rather on items thatindex.jsimports.Therefore, you'll want to accept specific things
index.jsimports, and use those from within, instead of trying to reloadindex.jswhich won't work without restarting the process.