Heroku R14 没有明显原因的警告可能是严格模式问题?

Heroku R14 warning for no apparent reason maybe strict mode problem?

我的应用程序收到 R14 警告,所以我确实将我的应用程序缩减为仅主页以跟踪问题,但发生了什么警告仍然存在,不知道是什么原因造成的?我有点担心我的 package.json 是错误的,所以基本上我的应用程序只是主页,没有任何功能,可能是我的启动脚本是错误的,应用程序是在 dev 中启动的?我也有严格模式问题如何在生产中禁用严格模式?我不得不注释掉严格模式,因为应用程序出于某种原因正在以严格模式部署?

2022-01-10T19:45:53.658182+00:00 heroku[web.1]: Process running mem=551M(107.7%)
2022-01-10T19:45:53.663719+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "engines": {
    "node": "14.17.4",
    "npm": "6.14.14"
  },
  "dependencies": {
    "@emotion/react": "^11.7.1",
    "@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",
    "@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"
    ]
  }
}

您的 start 脚本运行 react-scripts start:

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

这几乎肯定是错误的。

假设这是一个独立的应用程序,React 实际上不应该是 Heroku 上的 运行。相反,您应该在编译时构建一个生产版本,然后 Heroku 只需要将您的文件作为静态文件托管。这使用 非常 很少的内存。

一种选择是使用 this buildpack, which promises a zero-config way to get apps created via create-react-app up and running on Heroku:

This buildpack deploys a React UI as a static web site. The Nginx web server provides optimum performance and security for the runtime.

Configure your app to use this buildpack:

heroku buildpacks:set mars/create-react-app

然后.