[英]Error code ELIFECYCLE when pushing app to Heroku
我正在嘗試將我的 angular 項目應用程序推送到 Heroku 但這樣做會收到錯誤。 我已經看到有關刪除 node_modules 和安裝 npm 的線程,但是,這對我不起作用。
這是構建日志的樣子:
-----> Installing dependencies
Installing node modules
> nice-napi@1.0.2 install /tmp/build_5dc438c0/node_modules/nice-napi
> node-gyp-build
> esbuild@0.14.2 postinstall /tmp/build_5dc438c0/node_modules/esbuild
> node install.js
> core-js@3.19.3 postinstall /tmp/build_5dc438c0/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> @angular/cli@13.1.2 postinstall /tmp/build_5dc438c0/node_modules/@angular/cli
> node ./bin/postinstall/script.js
added 970 packages in 13.182s
-----> Build
Detected both "build" and "heroku-postbuild" scripts
Running heroku-postbuild
> project-fatj1700@0.0.0 heroku-postbuild /tmp/build_5dc438c0
> ng build --prod
Node.js version v12.18.2 detected.
The Angular CLI requires a minimum Node.js version of either v12.20, v14.15, or v16.10.
Please update your Node.js version or visit https://nodejs.org/ for additional instructions.
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! project-fatj1700@0.0.0 heroku-postbuild: `ng build --prod`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the project-fatj1700@0.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.RLDGy/_logs/2022-01-12T13_45_01_544Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
我能做些什么來解決這個錯誤?
將“node”:“12.20.x”添加到“engines”后:
2022-01-12T14:33:47.000000+00:00 app[api]: Build started by user fabian.tjernstrom@gmail.com
2022-01-12T14:35:25.273203+00:00 app[api]: Deploy 8d86c039 by user fabian.tjernstrom@gmail.com
2022-01-12T14:35:25.273203+00:00 app[api]: Release v4 created by user fabian.tjernstrom@gmail.com
2022-01-12T14:35:26.735671+00:00 heroku[web.1]: State changed from crashed to starting
2022-01-12T14:35:31.764566+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-12T14:35:33.514980+00:00 app[web.1]:
2022-01-12T14:35:33.514991+00:00 app[web.1]: > project-fatj1700@0.0.0 start /app
2022-01-12T14:35:33.514991+00:00 app[web.1]: > ng serve
2022-01-12T14:35:33.514991+00:00 app[web.1]:
2022-01-12T14:35:33.520075+00:00 app[web.1]: sh: 1: ng: not found
2022-01-12T14:35:33.528901+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-12T14:35:33.529008+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-12T14:35:33.529086+00:00 app[web.1]: npm ERR! file sh
2022-01-12T14:35:33.529172+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-12T14:35:33.531393+00:00 app[web.1]: npm ERR! project-fatj1700@0.0.0 start: `ng serve`
2022-01-12T14:35:33.531443+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-12T14:35:33.531502+00:00 app[web.1]: npm ERR!
2022-01-12T14:35:33.531554+00:00 app[web.1]: npm ERR! Failed at the project-fatj1700@0.0.0 start script.
2022-01-12T14:35:33.531599+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-12T14:35:33.536011+00:00 app[web.1]:
2022-01-12T14:35:33.536202+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-01-12T14:35:33.536297+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-01-12T14_35_33_532Z-debug.log
2022-01-12T14:35:33.669631+00:00 heroku[web.1]: Process exited with status 1
2022-01-12T14:35:33.823240+00:00 heroku[web.1]: State changed from starting to crashed
2022-01-12T14:35:33.842552+00:00 heroku[web.1]: State changed from crashed to starting
2022-01-12T14:35:38.370015+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-12T14:35:40.529105+00:00 app[web.1]:
2022-01-12T14:35:40.529133+00:00 app[web.1]: > project-fatj1700@0.0.0 start /app
2022-01-12T14:35:40.529133+00:00 app[web.1]: > ng serve
2022-01-12T14:35:40.529133+00:00 app[web.1]:
2022-01-12T14:35:40.532506+00:00 app[web.1]: sh: 1: ng: not found
2022-01-12T14:35:40.536788+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-12T14:35:40.536888+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-12T14:35:40.536955+00:00 app[web.1]: npm ERR! file sh
2022-01-12T14:35:40.537028+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-12T14:35:40.539163+00:00 app[web.1]: npm ERR! project-fatj1700@0.0.0 start: `ng serve`
2022-01-12T14:35:40.539208+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-12T14:35:40.539258+00:00 app[web.1]: npm ERR!
2022-01-12T14:35:40.539306+00:00 app[web.1]: npm ERR! Failed at the project-fatj1700@0.0.0 start script.
2022-01-12T14:35:40.539355+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-12T14:35:40.544701+00:00 app[web.1]:
2022-01-12T14:35:40.544777+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-01-12T14:35:40.544816+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2022-01-12T14_35_40_539Z-debug.log
2022-01-12T14:35:40.665966+00:00 heroku[web.1]: Process exited with status 1
2022-01-12T14:35:40.748773+00:00 heroku[web.1]: State changed from starting to crashed
2022-01-12T14:35:42.234593+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=miun-project-angular.herokuapp.com request_id=096b472c-7443-40cd-ba7f-b26afa11cc0a fwd="78.67.87.44" dyno=
connect= service= status=503 bytes= protocol=https
2022-01-12T14:35:42.443809+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=miun-project-angular.herokuapp.com request_id=ff6630c8-1a6c-45f3-9d68-ab729c25ccd9 fwd="78.67.87.44" dyno= connect= service= status=503 bytes= protocol=https
2022-01-12T14:35:43.000000+00:00 app[api]: Build succeeded
2022-01-12T14:35:46.092795+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=miun-project-angular.herokuapp.com request_id=34abf454-a40f-48bf-bf92-fd91e9792dea fwd="78.67.87.44" dyno=
connect= service= status=503 bytes= protocol=https
2022-01-12T14:35:46.297579+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=miun-project-angular.herokuapp.com request_id=bb11c150-6a4d-4cf7-b4be-20711731d61d fwd="78.67.87.44" dyno= connect= service= status=503 bytes= protocol=https
2022-01-12T14:35:59.357083+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=miun-project-angular.herokuapp.com request_id=cfd5c527-5b21-4d03-b08a-7e96c98caac1 fwd="78.67.87.44" dyno=
connect= service= status=503 bytes= protocol=https
2022-01-12T14:35:59.570612+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=miun-project-angular.herokuapp.com request_id=7788fb21-3137-41ef-9ad2-3d529f32266f fwd="78.67.87.44" dyno= connect= service= status=503 bytes= protocol=https
2022-01-12T14:38:08.475690+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=miun-project-angular.herokuapp.com request_id=6d3c3250-a75e-440a-925c-db8b58dc1416 fwd="78.67.87.44" dyno=
connect= service= status=503 bytes= protocol=https
2022-01-12T14:38:08.684035+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=miun-project-angular.herokuapp.com request_id=d05edfd2-984f-433c-9c10-47eed273e9a9 fwd="78.67.87.44" dyno= connect= service= status=503 bytes= protocol=https
2022-01-12T14:38:15.011568+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=miun-project-angular.herokuapp.com request_id=c68e2058-114b-4342-8914-1795524319b6 fwd="78.67.87.44" dyno= connect= service= status=503 bytes= protocol=https
2022-01-12T14:38:14.772764+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=miun-project-angular.herokuapp.com request_id=73fde94f-dfee-4e8b-80e8-924cb59755f7 fwd="78.67.87.44" dyno=
connect= service= status=503 bytes= protocol=https
2022-01-12T14:38:17.861635+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=miun-project-angular.herokuapp.com request_id=e1c0e987-e39d-4994-b8f5-f7f38c28e066 fwd="78.67.87.44" dyno=
connect= service= status=503 bytes= protocol=https
2022-01-12T14:38:18.101642+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=miun-project-angular.herokuapp.com request_id=932a731b-a49b-48b2-a56c-b524b5f6aee1 fwd="78.67.87.44" dyno= connect= service= status=503 bytes= protocol=https
看起來錯誤出在package.json
中的 Angular 構建腳本中,而不是 Z1A794174361C9ADBE88EFAD9B 本身。
Angular CLI 在錯誤中顯示它至少需要 Node.js v12.20
,但您當前使用的是v12.18.2
。
要強制 Heroku 使用特定版本的 Node,您可以在package.json
中的engines
object 中指定版本
只需將其添加到您的package.json
並將應用程序重新部署到 Heroku。
"engines": {
"node": "12.20.x"
}
我建議在部署新項目時使用最新的 LTS 版本,以盡可能長時間地保持最新狀態。
可以在此處找到有關使用自定義構建參數將 Node 應用程序部署到 Heroku 的其他文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.