React create app hot reload is not always working on linux
When npm start doesn’t detect changes, below are the common troubleshooting steps provided in the create-react-app
documentation - link.
While an app is running with npm start
and updating code in the editor should possibly refresh the broswer with the updated code.
If this doesn’t happen, try one of the following workarounds:
- If the project files are directly synced to your local system from a cloud storage like Dropbox or Google Drive and you're trying to run the app in them directly, try moving it out.
- Due to Webpack bug, you may need to restart the watcher. If the watcher doesn’t detect the index.js and you’re referencing it by the folder name.
- Safe write feature in editors like Vim and IntelliJ currently breaks the watcher. You will need to disable it.
- Due to Webpack watcher bug, projects with path contains parentheses causes issue, try moving the project to a path without them. .
- To allow more watchers in Linux and macOS, you might need to tweak system settings.
- If the project runs inside a virtual machine such as (a Vagrant provisioned) VirtualBox, create an
.env
file in your project directory if it doesn’t exist, and addCHOKIDAR_USEPOLLING=true
to it. This ensures that the next time you runnpm start
, the watcher uses the polling mode, as necessary inside a VM. - Could try increasing
max_users_watches
- link
More references:
- Issue Tracker 1
- Troubleshooting webpack
- Issue Tracker 2 - Webpack polling
Try these:
- Turn off safe write in your IDE
- Increase
max_user_watches
- Your path should not have parentheses
as last resort try to use this as your env variable:
CHOKIDAR_USEPOLLING=true npm start
Sources: https://github.com/facebookincubator/create-react-app/issues/659 https://github.com/facebookincubator/create-react-app/issues/1049#issuecomment-261731734