将以前工作的应用程序部署到 heroku 时出现 R14 和 H10 错误?

R14 and H10 erorr when deploying a previously working app to heruku?

我在启用应用程序的某些部分时收到以下错误,换句话说,应用程序运行正常,但我在过去几周添加了一些功能并尝试部署更新,但我开始收到这些错误,任何想法是什么原因造成的我检查了新添加的组件,但似乎没有任何问题......如果我注释掉这些组件,应用程序运行正常......真的很难确定发生了什么任何人有同样的问题?

  // a use memo insde of hook 
  const convertedObject = useMemo(() => {
    return Object.entries(context.icons)
      .filter((e) => !arrFilter.includes(e[0]))
      .map((e) => ({ item: '', key: e[0], src: e[1] }));
  }, [context.options]);

2022-01-08T03:47:17.797018+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp.herokuapp.com request_id=b2899edb-9996-42be-b8a5-42b3f9eeca6d fwd="46.135.6.18" dyno= connect= service= status=503 bytes= protocol=https 2022-01-08T03:47:18.126033+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=herokuapp.com request_id=ad15abf1-201b-4e5a-a029-9be71d008d0a fwd="46.135.6.18" dyno= connect= service= status=503 bytes= protocol=https

{
  "name": "myapp-that-is-driving-me-crazy",
  "version": "0.1.0",
  "private": true,
  "engines": {
    "node": "14.17.4",
    "npm": "6.14.14"
  },
  "dependencies": {
    "@emotion/react": "^11.7.0",
    "@emotion/styled": "^11.6.0",
    "@material-ui/core": "^4.12.3",
    "@material-ui/icons": "^4.11.2",
    "@material-ui/lab": "^4.0.0-alpha.60",
    "@mui/material": "^5.2.1",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "@types/html2canvas": "^1.0.0",
    "@types/jest": "^27.0.2",
    "@types/jspdf": "^2.0.0",
    "@types/node": "^16.11.6",
    "@types/react": "^17.0.33",
    "@types/react-dom": "^17.0.10",
    "@types/react-router-dom": "^5.3.2",
    "@types/uuid": "^8.3.3",
    "html2canvas": "^1.3.3",
    "jspdf": "^2.4.0",
    "notistack": "^1.0.10",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-ga": "^3.3.0",
    "react-router-dom": "^5.3.0",
    "react-scripts": "4.0.3",
    "typescript": "^4.4.4",
    "uuid": "^8.3.2",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

我建议您添加包 serve
将您的脚本更改为:

"scripts": {
    "start": "serve -s build",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "heroku-postbuild": "npm run build"
  },

如果上述方法不能解决问题,我建议使用构建包,例如 this