节点未在 Heroku 上正确部署的 Ionic 应用程序

Posted

技术标签:

【中文标题】节点未在 Heroku 上正确部署的 Ionic 应用程序【英文标题】:Ionic app with node not deploying correctly on Heroku 【发布时间】:2022-01-16 11:39:29 【问题描述】:

我有一个 ionic 程序,我正在尝试将它部署到 heroku,但它给了我这个错误:

2021-12-12T13:20:32.269136+00:00 app[web.1]: - Generating browser application bundles (phase: setup)...
2021-12-12T13:20:49.881823+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-12-12T13:20:49.912813+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-12-12T13:20:50.102339+00:00 heroku[web.1]: Process exited with status 137
2021-12-12T13:20:50.173468+00:00 heroku[web.1]: State changed from starting to crashed
2021-12-12T13:24:11.000000+00:00 app[api]: Build started by user sergioml2000@gmail.com
2021-12-12T13:26:30.635761+00:00 app[api]: Deploy 83d7c481 by user sergioml2000@gmail.com
2021-12-12T13:26:30.635761+00:00 app[api]: Release v5 created by user sergioml2000@gmail.com
2021-12-12T13:26:31.297561+00:00 heroku[web.1]: State changed from crashed to starting
2021-12-12T13:26:41.118110+00:00 heroku[web.1]: Starting process with command `npm run build && npm start`
2021-12-12T13:26:42.104400+00:00 app[web.1]:
2021-12-12T13:26:42.104411+00:00 app[web.1]: > sigevaMantUI@0.0.1 build /app
2021-12-12T13:26:42.104411+00:00 app[web.1]: > ng build --prod
2021-12-12T13:26:42.104411+00:00 app[web.1]:
2021-12-12T13:26:42.648877+00:00 app[web.1]: Option "--prod" is deprecated: Use "--configuration production" instead.
2021-12-12T13:26:44.791613+00:00 app[web.1]: - Generating browser application bundles (phase: setup)...
2021-12-12T13:26:45.000000+00:00 app[api]: Build succeeded
2021-12-12T13:27:14.252438+00:00 heroku[web.1]: Process running mem=874M(170.8%)
2021-12-12T13:27:14.254036+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2021-12-12T13:27:35.021299+00:00 heroku[web.1]: Process running mem=923M(180.3%)
2021-12-12T13:27:35.022699+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2021-12-12T13:27:41.252535+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-12-12T13:27:41.288420+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-12-12T13:27:41.863714+00:00 heroku[web.1]: Process exited with status 137
2021-12-12T13:27:41.912756+00:00 heroku[web.1]: State changed from starting to crashed

我的 package.json 是:


  "name": "sigevaMantUI",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "engines": 
    "node": "14.x",
    "npm": "6.14.15"
  ,
  "scripts": 
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "watch": "ng build --watch --configuration development",
    "prepush": "npm run build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "preinstall": "npm i -g http-server && npm i -g @angular/cli"
  ,
  "private": true,
  "dependencies": 
    "@angular/cli": "~12.1.1",
    "@angular/compiler": "~12.1.1",
    "@angular/compiler-cli": "~12.1.1",
    "@angular-devkit/build-angular": "~12.1.1",
    "@capacitor/cli": "3.3.2",
    "@ionic/angular-toolkit": "^4.0.0",
    "@angular-eslint/builder": "~12.0.0",
    "@angular-eslint/eslint-plugin": "~12.0.0",
    "@angular-eslint/eslint-plugin-template": "~12.0.0",
    "@angular-eslint/template-parser": "~12.0.0",
    "@angular/common": "~12.1.1",
    "@angular/core": "~12.1.1",
    "@angular/forms": "~12.1.1",
    "@angular/platform-browser": "~12.1.1",
    "@angular/platform-browser-dynamic": "~12.1.1",
    "@angular/router": "~12.1.1",
    "@capacitor/app": "1.0.6",
    "@capacitor/core": "3.3.2",
    "@capacitor/haptics": "1.1.3",
    "@capacitor/keyboard": "1.1.3",
    "@capacitor/status-bar": "1.0.6",
    "@ionic/angular": "^5.5.2",
    "rxjs": "~6.6.0",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4",
    "typescript": "~4.2.4"
  ,
  "devDependencies": 
    "@angular/language-service": "~12.0.1",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@typescript-eslint/eslint-plugin": "4.16.1",
    "@typescript-eslint/parser": "4.16.1",
    "eslint": "^7.6.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "30.7.6",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0"
  ,
  "description": "An Ionic project"

过程文件

web: npm run build && npm start

当我在本地执行它时,它工作正常。但是,当我将它推送到 Heroku 时,它告诉我发生了一个应用程序错误,我必须输入这个命令“heroku logs --tail”才能看到我之前输入的错误。

【问题讨论】:

请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。 【参考方案1】:

有2个问题:

错误 R14(超出内存配额) 错误 R10(启动超时)-> Web 进程未能在启动后 60 秒内绑定到 $PORT

为了减少内存占用,请尝试删除您可能不需要的依赖项。如果这还不够,您需要调试代码以查看过度分配的位置并重构代码

当你bind to the $PORT Heroku 提供时,第二个错误解决了

【讨论】:

我试过了,但是对我不起作用。它总是告诉我错误 R10。

以上是关于节点未在 Heroku 上正确部署的 Ionic 应用程序的主要内容,如果未能解决你的问题,请参考以下文章

React 和 Django 网站未在 Heroku 上加载

Rails 4图像未在heroku上加载

Heroku:Django Migration 版本未在部署中运行

Laravel 密码重置电子邮件未在 Heroku 上使用 gmail 发送

Ratyrate 星未在生产中加载(heroku)

'无法找到该进程类型'heroku节点部署