webpack-dev-server runs, but saving a file does not rebuild or reload
Nothing rebuilds after saving a fileShort answer
Watching fails when the operating system does not send file events (Docker, VirtualBox, WSL, network drives), when Linux runs out of inotify watchers, when the editor saves in a way that hides the change, or when the changed file sits outside the module graph and static folder. Turn on polling first, then check the others.
Fix it fast
1Find out which cause you have
Run webpack in watch mode with progress output and save a file. Progress lines on save mean webpack sees the change and the problem is in your config; no output means the file events never arrive.
npx webpack --watch --progress2Match what you see, then jump to its fix
- 1
Saves are ignored only inside Docker, VirtualBox, WSL or on an NFS share; the same project watches fine on the host.The project is in a container, VM or network folderFix - 2
A Not Enough Watchers message, or watching works for a small project and stops on a big one.Linux has run out of file watchersFix - 3
Only some editors trigger a rebuild; saving from the terminal with touch does.The editor saves in a way the watcher cannot seeFix - 4
Changes to .php, .html or other server-rendered templates never reload the page, while JavaScript changes do.The changed file is not part of the bundle or the static folderFix
- 1
What does the error look like?
Nothing rebuilds after saving a fileNot Enough Watchers
Cause 1 of 4
The project is in a container, VM or network folder
1Check
The docs say polling may help with NFS and with machines in VirtualBox, WSL, containers or Docker.
cat /proc/1/cgroup | head -32Fix
Turn on polling and ignore node_modules so the extra CPU cost stays small.
module.exports = {
watchOptions: {
poll: 1000,
ignored: /node_modules/,
},
};3Verify
Save a source file and watch the rebuild start within about a second.
npx webpack --watch --progressConfirmed by webpack.js.org
Cause 2 of 4
Linux has run out of file watchers
1Check
Read the current limit. The docs suggest raising it to 524288 when it is low.
cat /proc/sys/fs/inotify/max_user_watches2Fix
Raise the limit and reload the sysctl settings.
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p3Verify
Read the value again and restart the dev server.
cat /proc/sys/fs/inotify/max_user_watchesConfirmed by webpack.js.org
Cause 3 of 4
The editor saves in a way the watcher cannot see
1Check
The docs list two cases. Vim with backupcopy set to auto can replace the file instead of writing it, and WebStorm's option to back up files before saving can hide the change.
touch src/index.js
# in Vim: :set backupcopy?2Fix
In Vim run the setting below; in WebStorm turn off the back-up-before-saving option.
:set backupcopy=yes3Verify
Edit and save a file in the editor and watch the terminal.
npx webpack --watch --progressConfirmed by webpack.js.org
Cause 4 of 4
The changed file is not part of the bundle or the static folder
1Check
The dev server watches files served from static.directory (public by default) and the webpack module graph. Anything else needs devServer.watchFiles.
grep -n -E "static|watchFiles" webpack.config.*2Fix
List the extra globs to watch. Also make sure static.watch has not been set to false.
module.exports = {
devServer: {
watchFiles: ['src/**/*.php', 'public/**/*'],
},
};3Verify
Edit one of those files and confirm the page reloads.
npx webpack serveConfirmed by webpack.js.org
How do I stop it coming back?
- In Docker and VM setups, put the polling options in the config from day one.
- Ignore node_modules in watchOptions.
- Keep the project on the Linux filesystem inside WSL, not on a mounted Windows drive, where it is possible.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
corepack enable writes small link files for yarn and pnpm next to your node binary.
2 causes, each with a fixBack end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fixBack end
firebase deploy stops because the predeploy lint step failed
Error: There was an error deploying functions
The predeploy hook in firebase.json runs npm run lint before every deploy, and a failing hook cancels the deploy.
3 causes, each with a fixBack end
fluent-ffmpeg cannot find the ffmpeg or ffprobe binary
Error: Cannot find ffprobe
fluent-ffmpeg does not bundle ffmpeg.
4 causes, each with a fix