React Create App Hot Reload并非总是在Linux上运行 [英] React create app hot reload is not always working on linux

查看:112
本文介绍了React Create App Hot Reload并非总是在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:

  1. 如果将项目文件从Dropbox或Google Drive这样的云存储直接同步到本地系统,并且您尝试直接在其中运行应用程序,请尝试将其移出.
  2. 由于Webpack的错误,您可能需要重新启动观察程序 .如果观察者没有检测到index.js,而您是通过文件夹名称引用它的.
  3. 目前,Vim和IntelliJ等编辑器中的
  4. 安全写入功能使监视程序中断.您需要将其禁用.
  5. 由于 Webpack watcher错误,带有路径的项目包含括号会导致问题,请尝试移动将项目推向没有他们的道路.
  6. 要在Linux和macOS中允许更多观察者,您可能需要进行调整系统设置.
  7. 如果项目在虚拟机(例如由Vagrant提供的VirtualBox)中运行,请在项目目录中创建.env文件(如果不存在),然后添加CHOKIDAR_USEPOLLING=true.这样可以确保下次运行npm start时,监视程序会根据需要在VM内部使用轮询模式.
  8. 可以尝试增加max_users_watches-链接
  1. 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.
  2. 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.
  3. Safe write feature in editors like Vim and IntelliJ currently breaks the watcher. You will need to disable it.
  4. Due to Webpack watcher bug, projects with path contains parentheses causes issue, try moving the project to a path without them. .
  5. To allow more watchers in Linux and macOS, you might need to tweak system settings.
  6. 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 add CHOKIDAR_USEPOLLING=true to it. This ensures that the next time you run npm start, the watcher uses the polling mode, as necessary inside a VM.
  7. Could try increasing max_users_watches- link

更多参考:

  • Issue Tracker 1
  • Toubleshooting webpack
  • Issue Tracker 2 - Webpack polling

这篇关于React Create App Hot Reload并非总是在Linux上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆