简体   繁体   English

反应项目编译成功但不显示在浏览器上

[英]react project compiled successfully but dont show on browser

I did several react projects before but it is the first time I encountered this problem.之前做过几个react项目,但是第一次遇到这个问题。 After I ran我跑了之后

npx create-react-app myapp cd myapp npx create-react-app myapp cd myapp

I created a react project, then I ran我创建了一个反应项目,然后我跑了

npm start启动

It looks very fine:它看起来非常好:

enter image description here在此处输入图片说明

However, the project did not show in the browser, when I go to the localhost:3000 it reminds me "This site can't be reached":但是,该项目没有在浏览器中显示,当我转到 localhost:3000 时,它提醒我“无法访问此站点”:

enter image description here在此处输入图片说明

I tried to change the port but no matter what I do, this situation still lasts.我尝试更改端口,但无论我做什么,这种情况仍然存在。 The environment is good, the computer is good, the nodejs is good, anyone has encountered this kind of situation before can give me some advice?环境好,电脑好,nodejs好,以前有没有遇到过这种情况的可以给点建议吗? Thanks!谢谢!

This is happening because of the env variable HOST .这是由于 env 变量HOST

To fix that you need to add HOST="localhost" to your ~.bash_profile file, and then reload the env variables using source ~/.bash_profile .要解决此问题,您需要将HOST="localhost"添加到~.bash_profile文件中,然后使用source ~/.bash_profile重新加载环境变量。 (don't forget to restart your server) (不要忘记重启你的服务器)

This should fix your problem.这应该可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM