create-react-app的开发服务器不会自动刷新 [英] Development server of create-react-app does not auto refresh

查看:1021
本文介绍了create-react-app的开发服务器不会自动刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用create-react-app关注React的教程
该应用程序由 create-react-app v1.3.0创建

I am following a tutorial on React using create-react-app. The application is created by create-react-app v1.3.0

create-react-app my-app

开发服务器由

npm start

多次更改代码后,浏览器不会更新实时/热重新加载更改。刷新浏览器没有帮助。只停止开发服务器并重新启动它才能捕获对代码的新更改。

After changing the code several times, the browser is not updated live / hot reload with the changes. Refreshing the browser does not help. Only stopping the dev server and starting it over again capture the new changes to the code.

推荐答案

您是否看过疑难解答用户指南的部分?

它描述了此问题的几个常见原因

Have you seen the "Troubleshooting" section of the User Guide?
It describes a few common causes of this problem:


npm start 正在运行时保存文件时,浏览器应刷新更新的代码。

When you save a file while npm start is running, the browser should refresh with the updated code.

如果没有发生这种情况,请尝试以下解决方法之一:

If this doesn’t happen, try one of the following workarounds:

  • If your project is in a Dropbox folder, try moving it out.
  • If the watcher doesn’t see a file called index.js and you’re referencing it by the folder name, you need to restart the watcher due to a Webpack bug.
  • Some editors like Vim and IntelliJ have a "safe write" feature that currently breaks the watcher. You will need to disable it. Follow the instructions in "Working with editors supporting safe write".
  • If your project path contains parentheses, try moving the project to a path without them. This is caused by a Webpack watcher bug.
  • On Linux and macOS, you might need to tweak system settings to allow more watchers.
  • 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.

如果这些解决方案都没有帮助请发表评论在这个主题中

If none of these solutions help please leave a comment in this thread.

我希望这会有所帮助!

这篇关于create-react-app的开发服务器不会自动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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