Node.js/ Ionic 应用程序未在 Heroku 上正确部署
Posted
技术标签:
【中文标题】Node.js/ Ionic 应用程序未在 Heroku 上正确部署【英文标题】:Node.js/ Ionic app not deploying correctly on Heroku 【发布时间】:2022-01-15 21:28:33 【问题描述】:我有一个 ionic 程序,我正在尝试将它部署到 heroku,但它给了我这个错误:
2021-12-11T16:50:35.223922+00:00 app[web.1]: <--- Last few GCs --->
2021-12-11T16:50:35.223922+00:00 app[web.1]:
2021-12-11T16:50:35.223928+00:00 app[web.1]: [23:0x51b46b0] 16250 ms: Mark-sweep (reduce) 254.0 (256.8) -> 253.1 (258.1) MB, 803.3 / 0.0 ms (average mu = 0.193, current mu = 0.109) allocation failure scavenge might not succeed
2021-12-11T16:50:35.223928+00:00 app[web.1]: [23:0x51b46b0] 16360 ms: Mark-sweep (reduce) 254.2 (257.3) -> 253.3 (258.3) MB, 92.7 / 0.1 ms (average mu = 0.189, current mu = 0.163) allocation failure scavenge might not succeed
2021-12-11T16:50:35.223928+00:00 app[web.1]:
2021-12-11T16:50:35.223958+00:00 app[web.1]:
2021-12-11T16:50:35.223959+00:00 app[web.1]: <--- JS stacktrace --->
2021-12-11T16:50:35.223959+00:00 app[web.1]:
2021-12-11T16:50:35.223993+00:00 app[web.1]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - javascript heap out of memory
2021-12-11T16:50:35.224808+00:00 app[web.1]: 1: 0xa389b0 node::Abort() [ng build]
2021-12-11T16:50:35.225391+00:00 app[web.1]: 2: 0x96e0af node::FatalError(char const*, char const*) [ng build]
2021-12-11T16:50:35.225980+00:00 app[web.1]: 3: 0xbb7a4e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ng build]
2021-12-11T16:50:35.226582+00:00 app[web.1]: 4: 0xbb7dc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ng build]
2021-12-11T16:50:35.227270+00:00 app[web.1]: 5: 0xd73fd5 [ng build]
2021-12-11T16:50:35.228032+00:00 app[web.1]: 6: 0xd74b5f [ng build]
2021-12-11T16:50:35.228672+00:00 app[web.1]: 7: 0xd8299b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng build]
2021-12-11T16:50:35.229374+00:00 app[web.1]: 8: 0xd8655c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [ng build]
2021-12-11T16:50:35.230077+00:00 app[web.1]: 9: 0xd54c3b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [ng build]
2021-12-11T16:50:35.230887+00:00 app[web.1]: 10: 0x109d21f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [ng build]
2021-12-11T16:50:35.231764+00:00 app[web.1]: 11: 0x1446379 [ng build]
2021-12-11T16:50:35.249314+00:00 app[web.1]: Aborted
2021-12-11T16:50:35.253943+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-12-11T16:50:35.254117+00:00 app[web.1]: npm ERR! errno 134
2021-12-11T16:50:35.256864+00:00 app[web.1]: npm ERR! sigevaMantUI@0.0.1 build: `ng build`
2021-12-11T16:50:35.256928+00:00 app[web.1]: npm ERR! Exit status 134
2021-12-11T16:50:35.256988+00:00 app[web.1]: npm ERR!
2021-12-11T16:50:35.257034+00:00 app[web.1]: npm ERR! Failed at the sigevaMantUI@0.0.1 build script.
2021-12-11T16:50:35.257076+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-12-11T16:50:35.259437+00:00 app[web.1]:
2021-12-11T16:50:35.259525+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-12-11T16:50:35.259559+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-12-11T16_50_35_257Z-debug.log
2021-12-11T16:50:35.399380+00:00 heroku[web.1]: Process exited with status 134
2021-12-11T16:50:35.481990+00:00 heroku[web.1]: State changed from starting to crashed
2021-12-11T16:50:35.486044+00:00 heroku[web.1]: State changed from crashed to starting
2021-12-11T16:50:48.467903+00:00 heroku[web.1]: Starting process with command `npm run build && npm start`
2021-12-11T16:50:49.784088+00:00 app[web.1]:
2021-12-11T16:50:49.784119+00:00 app[web.1]: > sigevaMantUI@0.0.1 build /app
2021-12-11T16:50:49.784119+00:00 app[web.1]: > ng build
2021-12-11T16:50:49.784120+00:00 app[web.1]:
2021-12-11T16:50:53.964018+00:00 app[web.1]: - Generating browser application bundles (phase: setup)...
2021-12-11T16:51:12.542795+00:00 app[web.1]:
2021-12-11T16:51:12.542804+00:00 app[web.1]: <--- Last few GCs --->
2021-12-11T16:51:12.542804+00:00 app[web.1]:
2021-12-11T16:51:12.542811+00:00 app[web.1]: [23:0x5bf96b0] 21661 ms: Mark-sweep 253.9 (258.1) -> 253.1 (258.3) MB, 395.3 / 0.0 ms (average mu = 0.365, current mu = 0.248) allocation failure scavenge might not succeed
2021-12-11T16:51:12.542811+00:00 app[web.1]: [23:0x5bf96b0] 22002 ms: Mark-sweep 254.2 (258.3) -> 253.3 (258.6) MB, 225.9 / 0.0 ms (average mu = 0.355, current mu = 0.336) allocation failure scavenge might not succeed
2021-12-11T16:51:12.542812+00:00 app[web.1]:
2021-12-11T16:51:12.542857+00:00 app[web.1]:
2021-12-11T16:51:12.542858+00:00 app[web.1]: <--- JS stacktrace --->
2021-12-11T16:51:12.542858+00:00 app[web.1]:
2021-12-11T16:51:12.542879+00:00 app[web.1]: FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
2021-12-11T16:51:12.543994+00:00 app[web.1]: 1: 0xa389b0 node::Abort() [ng build]
2021-12-11T16:51:12.544699+00:00 app[web.1]: 2: 0x96e0af node::FatalError(char const*, char const*) [ng build]
2021-12-11T16:51:12.545552+00:00 app[web.1]: 3: 0xbb7a4e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ng build]
2021-12-11T16:51:12.546329+00:00 app[web.1]: 4: 0xbb7dc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ng build]
2021-12-11T16:51:12.547229+00:00 app[web.1]: 5: 0xd73fd5 [ng build]
2021-12-11T16:51:12.547970+00:00 app[web.1]: 6: 0xda496e v8::internal::EvacuateNewSpaceVisitor::Visit(v8::internal::HeapObject, int) [ng build]
2021-12-11T16:51:12.548708+00:00 app[web.1]: 7: 0xdb09a6 v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, long*) [ng build]
2021-12-11T16:51:12.549427+00:00 app[web.1]: 8: 0xd9cb3f v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [ng build]
2021-12-11T16:51:12.550221+00:00 app[web.1]: 9: 0xd9cdb8 v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [ng build]
2021-12-11T16:51:12.550969+00:00 app[web.1]: 10: 0xd8f699 v8::internal::ItemParallelJob::Run() [ng build]
2021-12-11T16:51:12.551705+00:00 app[web.1]: 11: 0xdb2900 void v8::internal::MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks<v8::internal::FullEvacuator, v8::internal::MarkCompactCollector>(v8::internal::MarkCompactCollector*, v8::internal::ItemParallelJob*, v8::internal::MigrationObserver*, long) [ng build]
2021-12-11T16:51:12.552445+00:00 app[web.1]: 12: 0xdb319c v8::internal::MarkCompactCollector::EvacuatePagesInParallel() [ng build]
2021-12-11T16:51:12.553172+00:00 app[web.1]: 13: 0xdb3365 v8::internal::MarkCompactCollector::Evacuate() [ng build]
2021-12-11T16:51:12.553920+00:00 app[web.1]: 14: 0xdc5361 v8::internal::MarkCompactCollector::CollectGarbage() [ng build]
2021-12-11T16:51:12.554634+00:00 app[web.1]: 15: 0xd81628 v8::internal::Heap::MarkCompact() [ng build]
2021-12-11T16:51:12.555370+00:00 app[web.1]: 16: 0xd83118 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng build]
2021-12-11T16:51:12.556113+00:00 app[web.1]: 17: 0xd8655c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [ng build]
2021-12-11T16:51:12.556820+00:00 app[web.1]: 18: 0xd54c3b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [ng build]
2021-12-11T16:51:12.557662+00:00 app[web.1]: 19: 0x109d21f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [ng build]
2021-12-11T16:51:12.558546+00:00 app[web.1]: 20: 0x1446379 [ng build]
2021-12-11T16:51:12.611194+00:00 app[web.1]: Aborted
2021-12-11T16:51:12.617530+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-12-11T16:51:12.618021+00:00 app[web.1]: npm ERR! errno 134
2021-12-11T16:51:12.622001+00:00 app[web.1]: npm ERR! sigevaMantUI@0.0.1 build: `ng build`
2021-12-11T16:51:12.622062+00:00 app[web.1]: npm ERR! Exit status 134
2021-12-11T16:51:12.622134+00:00 app[web.1]: npm ERR!
2021-12-11T16:51:12.622189+00:00 app[web.1]: npm ERR! Failed at the sigevaMantUI@0.0.1 build script.
2021-12-11T16:51:12.622231+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-12-11T16:51:12.679508+00:00 app[web.1]:
2021-12-11T16:51:12.679707+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-12-11T16:51:12.679782+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-12-11T16_51_12_622Z-debug.log
2021-12-11T16:51:12.833383+00:00 heroku[web.1]: Process exited with status 134
2021-12-11T16:51:12.933277+00:00 heroku[web.1]: State changed from starting to crashed
2021-12-11T16:51:14.212720+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=app-sip.herokuapp.com request_id=9892600c-90fe-4c40-94cc-fb16bbf17334 fwd="37.132.227.60" dyno= connect= service= status=503 bytes= protocol=https
2021-12-11T16:51:14.223341+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=app-sip.herokuapp.com request_id=2f59fb49-b60b-45bf-b92c-63a83ba970dd fwd="37.132.227.60" dyno= connect= service= status=503 bytes= protocol=https
2021-12-11T16:51:14.961353+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=app-sip.herokuapp.com request_id=f71c6560-01e9-4cc0-9491-ca89e66d9180 fwd="37.132.227.60" dyno= connect= service= status=503 bytes= protocol=https
我的 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",
"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】:在堆限制附近的无效标记压缩分配失败 - JavaScript 堆内存不足...
也许是一组 Heroku...
试试这个:
【讨论】:
是的!有用。非常感谢。但是它给了我另一个错误:错误 R10(启动超时)-> Web 进程在启动后 60 秒内无法绑定到 $PORT。你知道该怎么做吗? 此外,它给了我这个错误:错误 R14(超出内存配额)。 Stai usando una porta già in uso?以上是关于Node.js/ Ionic 应用程序未在 Heroku 上正确部署的主要内容,如果未能解决你的问题,请参考以下文章
我可以在没有 node.js 的情况下使用 Ionic 来构建托管 Web 应用程序吗?