简体   繁体   中英

NextJS isn't updating when pages/containers/components are changed, HMR always returns success

I'm having an issue with NextJS / webpack .

Whenever I make changes, it won't update anything until a full restart of everything. This takes a really long time to compile, most recently 6.4 seconds for the client and 2.3 for the server. Often it has taken 20-30 seconds in the past.

process.env.NODE_ENV is undefined, webpack-hmr and on-demand-entries both always return empty/success in the browser. My guess would be that Next / Webpack aren't able to watch the files that are being changed.

My next version is 6.0.3 and I'm working in Ubuntu 16.04.4 lts in WSL on Windows 10.0.17134 .

The problem persists with a custom server, I'm calling app.getRequestHandler once, assigning it to handler, then routing get paths ( /{p*} ) to the handler with Hapi v17.5.2 .

If you happen to find this "question and solution" and it is still not working...

Try adding a .env with CHOKIDAR_USEPOLLING=true on it, this fixed it for me, because I am not storing the files inside WSL but in a different disk on Windows...

I added

config.node = {
  fs: 'empty'
}

and now it updates on file changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM