I created a react application using create-react-app boilerplate, which seems to be very popular, hot reload some times updates when any of the files changes and some times not, seems like there is a minimum duration or something like that, I'm using Ubuntu, node version 7.0, the script in package.json is npm:'react-script start'
what I am missing ?
相关问题
- How to toggle on Order in ReactJS
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Refreshing page gives Cannot GET /page_url in reac
- Is shmid returned by shmget() unique across proces
- Adding a timeout to a render function in ReactJS
Try these:
max_user_watches
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
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 borswer with the updated code. If this doesn’t happen, try one of the following workarounds:.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.max_users_watches
- linkMore references:
Apparently hot module reloading only works out-of-the-box if you eject your app.
But if you haven't ejected your app, then you can follow these instructions to get it working.
Find the
ReactDOM.render(...)
at the top of your app, and add these lines below it:The instructions linked above also show how to hot reload things outside of the component tree, such as redux reducers.
In unbuntu, i basically kill all the process running on port (for react app default is :3000).
List all the process running on port 3000.
lsof -i :3000
This command will show something like this.
Now kill the process by PID.
Start your react app again.
One additional case I just experience is when using multiple version of nodejs with NVM in parallel. Basically, I have two terminal windows, one run node 10.x, other on node 9.x, and Webpack watcher stops seeing change.
The solution is to bring both to the same node version
I was able to make this work using: