无法让 webpack 热加载器与 React 一起工作
Can't get webpack hot loader to work with React
我一直在尝试获取 webpack 热加载器的工作版本来进行实时编辑以开发应用程序。在学习了教程却无法进行实时编辑后,我决定从头开始。
我克隆了一个 React Hot Loader boilerplate and tried using Dan Abramov's create-react-app. I am able to build both apps. I am getting a log in the console that says [WDS] Hot Module Replacement enabled
but editing any files does not trigger a page reload or anything in terminal. In this troubleshooting page 的干净存储库,我属于这个类别:
I see “[WDS] Hot Module Replacement enabled” but nothing happens when I edit App.js
If you're running Node 0.11.13, you might want to try updating to 0.12. Some people reported this helped solve this problem. Also make sure that your requires have the same filename casing as the files. Having App.js and doingrequire('app') might trip the watcher on some systems.
OS X also has a rarely-occuring bug that causes some folders to get 'broken' with regards to file system change monitoring. Here are some suggested fixes.
我查看了故障排除指南的这一部分,但似乎没有任何效果。
我是 运行 npm v2.15.1 和 Ubuntu 16.04 中的节点 v4.2.6。
问题出在 Ubuntu 上的观察者身上。在 Ubuntu,我尝试检查 dmsesg
日志,它告诉我 inotify 资源已经耗尽,无法使用。
$ tail -f /var/log/dmesg
(Nothing has been logged yet.)
tail: inotify resources exhausted
tail: inotify cannot be used, reverting to polling
来自troubleshoot page of react-hot-loader:
Ubuntu users (and possibly others): echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
.
然后热加载程序按预期工作。
我一直在尝试获取 webpack 热加载器的工作版本来进行实时编辑以开发应用程序。在学习了教程却无法进行实时编辑后,我决定从头开始。
我克隆了一个 React Hot Loader boilerplate and tried using Dan Abramov's create-react-app. I am able to build both apps. I am getting a log in the console that says [WDS] Hot Module Replacement enabled
but editing any files does not trigger a page reload or anything in terminal. In this troubleshooting page 的干净存储库,我属于这个类别:
I see “[WDS] Hot Module Replacement enabled” but nothing happens when I edit App.js
If you're running Node 0.11.13, you might want to try updating to 0.12. Some people reported this helped solve this problem. Also make sure that your requires have the same filename casing as the files. Having App.js and doingrequire('app') might trip the watcher on some systems.
OS X also has a rarely-occuring bug that causes some folders to get 'broken' with regards to file system change monitoring. Here are some suggested fixes.
我查看了故障排除指南的这一部分,但似乎没有任何效果。
我是 运行 npm v2.15.1 和 Ubuntu 16.04 中的节点 v4.2.6。
问题出在 Ubuntu 上的观察者身上。在 Ubuntu,我尝试检查 dmsesg
日志,它告诉我 inotify 资源已经耗尽,无法使用。
$ tail -f /var/log/dmesg
(Nothing has been logged yet.)
tail: inotify resources exhausted
tail: inotify cannot be used, reverting to polling
来自troubleshoot page of react-hot-loader:
Ubuntu users (and possibly others):
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
.
然后热加载程序按预期工作。