【发布时间】:2019-09-07 06:25:18
【问题描述】:
我通过
构建了 react 项目npx create-react-app my-app
现在我跑了
npm start
下面是输出
Compiled successfully!
You can now view todos in the browser.
Local: http://localhost:3000/
On Your Network: http://192.168.31.146:3000/
Note that the development build is not optimized.
To create a production build, use npm run build.
我可以通过http://192.168.31.146:3000/访问我的项目, 但我无法通过http://localhost:3000/访问
如果我把 localhost 改成 127.0.0.1 就可以了。
我的问题是如何通过http://localhost:3000/访问我的项目
【问题讨论】:
-
对不起,我有三个问题: 1. 127.0.0.1:3000 有效吗? 2.你运行的是什么操作系统? 3.尝试不同的浏览器?
-
需要在hosts文件中添加
localhost 127.0.0.1