React Create App Hot Reload并非总是在Linux上运行 [英] React create app hot reload is not always working on linux
问题描述
我使用create-react-app样板创建了一个React应用程序,该应用程序似乎很流行,当任何文件发生更改时,热重载有时会更新,有时则不会,似乎有最小持续时间或类似的时间,我使用的是Ubuntu,节点版本为7.0,package.json中的脚本为npm:'react-script start'
我缺少的内容?
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 ?
推荐答案
当npm start无法检测到更改时,以下是create-react-app
文档中提供的常见故障排除步骤-
When npm start doesn’t detect changes, below are the common troubleshooting steps provided in the create-react-app
documentation - link.
虽然应用程序正在使用npm start
运行,并且在编辑器中更新代码可能应该使用更新的代码刷新连接.
如果没有发生,请尝试以下解决方法之一:
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:
- 如果将项目文件从Dropbox或Google Drive这样的云存储直接同步到本地系统,并且您尝试直接在其中运行应用程序,请尝试将其移出.
- 由于Webpack的错误,您可能需要重新启动观察程序 .如果观察者没有检测到index.js,而您是通过文件夹名称引用它的. 目前,Vim和IntelliJ等编辑器中的
- 安全写入功能使监视程序中断.您需要将其禁用.
- 由于 Webpack watcher错误,带有路径的项目包含括号会导致问题,请尝试移动将项目推向没有他们的道路.
- 要在Linux和macOS中允许更多观察者,您可能需要进行调整系统设置.
- 如果项目在虚拟机(例如由Vagrant提供的VirtualBox)中运行,请在项目目录中创建
.env
文件(如果不存在),然后添加CHOKIDAR_USEPOLLING=true
.这样可以确保下次运行npm start
时,监视程序会根据需要在VM内部使用轮询模式. - 可以尝试增加
max_users_watches
-链接
- If the project files are directly synced to your local system from a cloud storage like Dropbox or Google Drive and your 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
更多参考:
- Issue Tracker 1
- Toubleshooting webpack
- Issue Tracker 2 - Webpack polling
这篇关于React Create App Hot Reload并非总是在Linux上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!