简体   繁体   中英

Error code ELIFECYCLE when pushing app to Heroku

I'm trying to push my angular project app to Heroku but recieving errors doing so. I've seen threads about deleting node_modules and doing a npm install, however, this does not work for me.

This is what the build log looks like:

-----> 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

What can I do to get around this error?

After adding "node": "12.20.x" to "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

It looks like the error lies within your Angular build script in package.json rather than Heroku itself.

The Angular CLI shows in the error that it requires a minimum of Node.js v12.20 , but you are currently using v12.18.2 .

To force Heroku to use a specific version of Node, you can specify the version within the engines object in package.json .

Simply add this to your package.json and redeploy the app to Heroku.

"engines": {
    "node": "12.20.x"
}

I'd recommend using the most recent LTS version when deploying new projects to stay as up to date for as long as possible.

Additional documentation can be found here on deploying a Node app to Heroku with custom build parameters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM