[英]Issue about installation of New React App
I want to learn React. 我想学习React。 so I installed Nodejs(v 10.16.0 LTS) and then using Windows Powershell I run following commands
所以我安装了Nodejs(v 10.16.0 LTS),然后使用Windows Powershell运行以下命令
npx create-react-app my-app
cd my-app
npm start
After installing, When I try to make a change in any code (like changing page title name), after saving code file. 安装后,当我尝试在保存代码文件后更改任何代码(例如更改页面标题名称)时。 The Tab in Browser does not reload automatically and when I reload tab manually the error occurs which say
浏览器中的标签页不会自动重新加载,当我手动重新加载标签页时会出现错误,提示
This site can't be reached
无法访问该网站
localhost refused to connect.
本地主机拒绝连接。
Try:
尝试:
Checking the connection
检查连接
Checking the proxy and the firewall.
检查代理和防火墙。
If I start this using PowerShell using npm start* command, then it run successfully. 如果我使用npm start *命令使用PowerShell启动此程序 ,则它将成功运行。 but I have to do this every time even when I edit my code.
但是即使我在编辑代码时也必须每次都这样做。 Browser tab did not reload and apply changes automatically.
浏览器标签未重新加载并自动应用更改。
Kindly guide me about this issue. 请指导我有关这个问题。 Thanks
谢谢
You shouldn't need react-hot-loader
or anything else if you've created your react app through create-react-app
- just make sure you're using the latest stable version of create-react-app
如果您已经通过
create-react-app
创建了react应用,则无需使用react-hot-loader
或其他任何东西-只需确保您使用的是create-react-app
的最新稳定版本即可
In your react app, when you run npm start
, it uses react-scripts start
script which behind the scenes uses webpack
which actually takes care of hot module replacement 在您的React应用程序中,当您运行
npm start
,它使用react-scripts start
脚本,该脚本在后台使用webpack
来实际处理热模块更换
The problem you're facing seems most likely related to your local setup. 您面临的问题似乎最有可能与您的本地设置有关。 Can you try running your app on a different port
8080
maybe? 您可以尝试在其他端口
8080
上运行您的应用程序吗?
Secondly, hot module replacement uses a websocket connection, can you check in your console if there is any error related to ws connection? 其次,热模块更换使用websocket连接,您能否在控制台中检查与ws连接有关的任何错误?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.