【问题标题】:npm start can't access by localhostnpm start 无法通过 localhost 访问
【发布时间】: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

标签: node.js reactjs npm


【解决方案1】:

重新安装node.js并重启我的电脑,一切正常! 对不起

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-03
    • 1970-01-01
    • 2021-07-31
    • 2016-11-05
    • 2019-07-18
    • 2021-12-31
    • 2018-07-09
    相关资源
    最近更新 更多