【问题标题】:Reactjs deployement on Heroku App crashedHeroku App 上的 Reactjs 部署崩溃
【发布时间】:2020-05-21 23:21:53
【问题描述】:

我正在尝试在 Heroku 上部署 React 应用程序。我在日志文件中看到它的构建很好。在浏览器上运行它时,它会说,“正在启动开发服务器......”。但是突然就报错了。

进程以状态 0 退出。

状态从开始变为崩溃。

我在谷歌上搜索了很多,找到了很多解决这个特定错误的方法,但没有一个对我有用。

这是我的 package.json 文件:

"engines": {
    "node": "10.16.3",
    "npm": "6.1.0",
    "yarn": "1.22.4"
},

脚本:

"scripts": {
    "start": "react-scripts start",
    "dev": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
},

我使用的是纱线而不是 npm。

这是我在部署后单击查看按钮时所说的内容:

2020-05-21T23:10:18.672143+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testmystorespeed.herokuapp.com request_id=83e14391-8f4a-442b-8ee6-6904d095e258 fwd="39.42.33.31" dyno= connect= service= status=503 bytes= protocol=https

2020-05-21T23:10:20.773731+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=testmystorespeed.herokuapp.com request_id=e8a2be81-7d60-44f4-9746-f2e2f3789e79 fwd="39.42.33.31" dyno= connect= service= status=503 bytes= protocol=https

注意也许有人说这是一个重复的问题,但我已经尝试了我在 StackOverflow 和其他论坛中找到的几乎所有内容。

【问题讨论】:

    标签: node.js reactjs npm yarnpkg


    【解决方案1】:

    Heroku 主要用于动态应用程序。所以你可以尝试 netlify 甚至 github pages 来部署你的静态反应应用程序。

    这就是我的 Pokedex 应用程序的 package.json 在 github 页面上的部署方式。 https://github.com/AshutoshAgrawal2004/Pokedex

    {
    "name": "pokedex",
    "version": "0.1.0",
    "private": true,
    "homepage": "https://ashutoshagrawal2004.github.io/Pokedex",
    "dependencies": {
        "axios": "^0.19.0",
        "gh-pages": "^2.1.1",
        "react": "^16.9.0",
        "react-dom": "^16.9.0",
        "react-infinite-scroll-component": "^4.5.3",
        "react-redux": "^7.1.1",
        "react-router-dom": "^5.1.0",
        "react-scripts": "3.1.2",
        "redux": "^4.0.4",
        "redux-devtools-extension": "^2.13.8",
        "redux-thunk": "^2.3.0",
        "uuid": "^3.3.3"
    },
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "predeploy": "npm run build",
        "deploy": "gh-pages -d build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
    },
    "eslintConfig": {
        "extends": "react-app"
    },
    "browserslist": {
        "production": [
            ">0.2%",
            "not dead",
            "not op_mini all"
        ],
        "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
        ]
    }
    

    }

    这是一个教程https://medium.com/the-andela-way/how-to-deploy-your-react-application-to-github-pages-in-less-than-5-minutes-8c5f665a2d2a

    【讨论】:

      【解决方案2】:

      这可能是 Heroku 使用 node.js buildpack 默认阻止 create-react-app 部署的问题。

      【讨论】:

        猜你喜欢
        • 2017-06-24
        • 1970-01-01
        • 2012-10-02
        • 2021-12-21
        • 2019-05-21
        • 2015-12-25
        • 1970-01-01
        • 1970-01-01
        • 2022-10-07
        相关资源
        最近更新 更多