【问题标题】:When I run "npm start" to run a React app , it doesn't give any errors but hangs forever instead当我运行“npm start”来运行 React 应用程序时,它不会给出任何错误,而是永远挂起
【发布时间】:2019-04-26 13:32:41
【问题描述】:

在此之前我已经运行了“npm install”,并且所有必要的依赖项都已安装。

我也试过卸载旧版本的 NodeJS 并安装最新版本,但还是不行。

应该会弹出一个带有 React 应用程序的浏览器窗口。

我的 package.json 文件如下所示:

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "add": "^2.0.6",
    "bootstrap": "^4.1.3",
    "react": "^16.6.3",
    "react-bootstrap": "^0.32.4",
    "react-dom": "^16.6.3",
    "react-redux": "^5.1.1",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.1.1",
    "react-select": "^2.1.1",
    "redux": "^4.0.1",
    "yarn": "^1.12.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "proxy": "http://localhost:57111/"
}

【问题讨论】:

  • 您是否尝试手动访问该 URL?
  • 我们可以看看你的 package.json 脚本吗?

标签: reactjs npm npm-start


【解决方案1】:

浏览器无法自动打开网址可能有多种原因,但我们会通过在浏览器中手动打开网址来了解服务器是否启动。

通常在localhost 中的端口3000 中启动服务器。因此,当您使用 create-react-app 时,访问您网站的 URL 默认为 http://localhost:3000

尝试手动打开网站http://localhost:3000

【讨论】:

  • 非常感谢。该链接重定向到我的网站。但是你知道为什么它不能在浏览器中自动打开吗?
  • 可能有多种原因。 1. 浏览器自动打开有问题,2. 终端阻止打开浏览器窗口,3. 操作系统中的一些其他安全设置等。如果不深入研究,就无法确定。
  • 我也有这个问题。每当我运行npm start 时,我的系统都会严重挂起。我不知道该怎么办。 @Dinesh
【解决方案2】:

在 Mac 上发生在我身上。一个好的老式重启就可以了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 2021-03-11
    • 2022-01-20
    • 2019-01-12
    • 2019-10-02
    • 2015-02-01
    • 1970-01-01
    相关资源
    最近更新 更多