0

if I run the application from terminal, it is working, I mean that it is running in the browser. The problem is when I try to host it on Heroku. My app has Backend: Nodejs with Express and Database: MySQL. I see that I have errors, but I don't understand them and I've tried multiple things to make it work, but I can't. Logs from the error:

2022-01-14T11:42:19.516824+00:00 app[web.1]: 
2022-01-14T11:42:19.516835+00:00 app[web.1]: > presidentialelections@0.0.0 start /app
2022-01-14T11:42:19.516835+00:00 app[web.1]: > nodemon ./bin/www
2022-01-14T11:42:19.516835+00:00 app[web.1]: 
2022-01-14T11:42:19.520231+00:00 app[web.1]: sh: 1: nodemon: not found
2022-01-14T11:42:19.524055+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-14T11:42:19.524197+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-14T11:42:19.524258+00:00 app[web.1]: npm ERR! file sh
2022-01-14T11:42:19.524466+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-14T11:42:19.526613+00:00 app[web.1]: npm ERR! presidentialelections@0.0.0 start: `nodemon ./bin/www` 
2022-01-14T11:42:19.526650+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T11:42:19.526699+00:00 app[web.1]: npm ERR!
2022-01-14T11:42:19.526737+00:00 app[web.1]: npm ERR! Failed at the presidentialelections@0.0.0 start script.2022-01-14T11:42:19.526788+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-14T11:42:19.532863+00:00 app[web.1]:
2022-01-14T11:42:19.532933+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-01-14T11:42:19.532983+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2022-01-14T11_42_19_527Z-debug.log 
2022-01-14T11:42:19.647800+00:00 heroku[web.1]: Process exited with status 1
2022-01-14T11:42:19.723822+00:00 heroku[web.1]: State changed from starting to crashed
2022-01-14T11:42:22.997860+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pacific-ravine-23602.herokuapp.com request_id=867758f1-1252-4674-a7cc-261fbe9f98d1 fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T11:42:23.312967+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pacific-ravine-23602.herokuapp.com request_id=5cb55772-dad6-486d-bc15-d37731d94661 fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T11:46:57.000000+00:00 app[api]: Build started by user daviddserb@yahoo.com
2022-01-14T11:47:11.000000+00:00 app[api]: Build succeeded
2022-01-14T11:47:11.297457+00:00 app[api]: Deploy 7ee73460 by user daviddserb@yahoo.com
2022-01-14T11:47:11.297457+00:00 app[api]: Release v4 created by user daviddserb@yahoo.com
2022-01-14T11:47:12.210235+00:00 heroku[web.1]: State changed from crashed to starting
2022-01-14T11:47:14.084097+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-14T11:47:15.244156+00:00 app[web.1]:
2022-01-14T11:47:15.244170+00:00 app[web.1]: > presidentialelections@0.0.0 start /app
2022-01-14T11:47:15.244170+00:00 app[web.1]: > nodemon ./bin/www
2022-01-14T11:47:15.244170+00:00 app[web.1]:
2022-01-14T11:47:15.248738+00:00 app[web.1]: sh: 1: nodemon: not found
2022-01-14T11:47:15.254959+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-14T11:47:15.255206+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-14T11:47:15.255316+00:00 app[web.1]: npm ERR! file sh
2022-01-14T11:47:15.255405+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-14T11:47:15.259050+00:00 app[web.1]: npm ERR! presidentialelections@0.0.0 start: `nodemon ./bin/www` 
2022-01-14T11:47:15.259107+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T11:47:15.259167+00:00 app[web.1]: npm ERR!
2022-01-14T11:47:15.259216+00:00 app[web.1]: npm ERR! Failed at the presidentialelections@0.0.0 start script.2022-01-14T11:47:15.259274+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-14T11:47:15.266461+00:00 app[web.1]:
2022-01-14T11:47:15.266545+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-01-14T11:47:15.266590+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2022-01-14T11_47_15_260Z-debug.log 
2022-01-14T11:47:15.397039+00:00 heroku[web.1]: Process exited with status 1
2022-01-14T11:47:15.454442+00:00 heroku[web.1]: State changed from starting to crashed
2022-01-14T11:47:18.779406+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pacific-ravine-23602.herokuapp.com request_id=325e420b-9e58-4f7e-bad0-4872dc699fe0 fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T11:47:19.023207+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pacific-ravine-23602.herokuapp.com request_id=e081eb63-0cff-4e27-a710-1d60cbc9beb1 fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T11:48:40.000000+00:00 app[api]: Build started by user daviddserb@yahoo.com
2022-01-14T11:48:53.770119+00:00 app[api]: Deploy 7fc9ef13 by user daviddserb@yahoo.com
2022-01-14T11:48:53.770119+00:00 app[api]: Release v5 created by user daviddserb@yahoo.com
2022-01-14T11:48:54.000000+00:00 app[api]: Build succeeded
2022-01-14T11:48:54.117745+00:00 heroku[web.1]: State changed from crashed to starting
2022-01-14T11:48:55.999691+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-14T11:48:56.952415+00:00 app[web.1]:
2022-01-14T11:48:56.952427+00:00 app[web.1]: > presidentialelections@0.0.0 start /app
2022-01-14T11:48:56.952428+00:00 app[web.1]: > nodemon ./bin/www
2022-01-14T11:48:56.952428+00:00 app[web.1]:
2022-01-14T11:48:56.962683+00:00 app[web.1]: sh: 1: nodemon: not found
2022-01-14T11:48:56.968511+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-14T11:48:56.968735+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-14T11:48:56.968786+00:00 app[web.1]: npm ERR! file sh
2022-01-14T11:48:56.968886+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-14T11:48:56.972412+00:00 app[web.1]: npm ERR! presidentialelections@0.0.0 start: `nodemon ./bin/www` 
2022-01-14T11:48:56.972521+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T11:48:56.972620+00:00 app[web.1]: npm ERR!
2022-01-14T11:48:56.972734+00:00 app[web.1]: npm ERR! Failed at the presidentialelections@0.0.0 start script.2022-01-14T11:48:56.972822+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-14T11:48:56.977729+00:00 app[web.1]:
2022-01-14T11:48:56.977829+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-01-14T11:48:56.977880+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2022-01-14T11_48_56_974Z-debug.log 
2022-01-14T11:48:57.123929+00:00 heroku[web.1]: Process exited with status 1
2022-01-14T11:48:57.256711+00:00 heroku[web.1]: State changed from starting to crashed
2022-01-14T11:49:03.042405+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pacific-ravine-23602.herokuapp.com request_id=40e7bba7-b78d-4472-b652-c1b296a4343a fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T11:49:03.312210+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pacific-ravine-23602.herokuapp.com request_id=4b214bf1-4d44-4895-8bc7-2d8cc34e172d fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T11:51:59.531549+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pacific-ravine-23602.herokuapp.com request_id=c38f2d45-f1a5-43a9-9f4e-e2f34ef4d1bb fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T11:51:59.801198+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pacific-ravine-23602.herokuapp.com request_id=a5c7fb1c-5ce3-4ccf-81ac-3cb8fdce759f fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T11:56:02.383069+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pacific-ravine-23602.herokuapp.com request_id=22db8c3d-1714-42f8-a40f-9e02d0cc737a fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T11:56:02.634499+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pacific-ravine-23602.herokuapp.com request_id=fc256052-006a-4289-a836-ce8094e64944 fwd="86.120.247.90" dyno= connect= service= status=503 bytes= protocol=https
2022-01-14T12:05:20.233183+00:00 heroku[web.1]: State changed from crashed to starting
2022-01-14T12:05:22.754848+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-14T12:05:23.970064+00:00 app[web.1]:
2022-01-14T12:05:23.970078+00:00 app[web.1]: > presidentialelections@0.0.0 start /app
2022-01-14T12:05:23.970079+00:00 app[web.1]: > nodemon ./bin/www
2022-01-14T12:05:23.970079+00:00 app[web.1]:
2022-01-14T12:05:23.973595+00:00 app[web.1]: sh: 1: nodemon: not found
2022-01-14T12:05:23.978419+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-14T12:05:23.978592+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-14T12:05:23.978667+00:00 app[web.1]: npm ERR! file sh
2022-01-14T12:05:23.978764+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-14T12:05:23.981475+00:00 app[web.1]: npm ERR! presidentialelections@0.0.0 start: `nodemon ./bin/www`
2022-01-14T12:05:23.981519+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T12:05:23.981564+00:00 app[web.1]: npm ERR!
2022-01-14T12:05:23.982264+00:00 app[web.1]: npm ERR! Failed at the presidentialelections@0.0.0 start script.2022-01-14T12:05:23.982320+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There 
is likely additional logging output above.
2022-01-14T12:05:23.984901+00:00 app[web.1]:
2022-01-14T12:05:23.984998+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-01-14T12:05:23.985048+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2022-01-14T12_05_23_982Z-debug.log
2022-01-14T12:05:24.128019+00:00 heroku[web.1]: Process exited with status 1
2022-01-14T12:05:24.211507+00:00 heroku[web.1]: State changed from starting to crashed

I don't know what else to give you, so please, if you need some other files or information about my project, let me know and I will upload them.
Serb David
  • 33
  • 6
  • Does this answer your question? [Heroku failing node app - try to run nodemon instead of node](https://stackoverflow.com/q/48938520/354577) – ChrisGPT was on strike Jan 14 '22 at 13:36
  • TL;DR: this is (probably) failing because you have defined `nodemon` as a _dev_ dependency, and dev dependencies are pruned from Heroku builds by default. But that's good! You shouldn't be using nodemon on Heroku in the first place. Make sure your `start` script or `Procfile` run `node` instead of `nodemon`. – ChrisGPT was on strike Jan 14 '22 at 13:38
  • Yes, I've already tried this as well. I tried it again, so in my start script, I don't have nodemon anymore, I have: node ./bin/www but it's still not working. Do I have to reinstall like node_modules and package.json? I'm asking because it still says the exact same thing, nodemon not found, even tho I don't use it anymore... – Serb David Jan 14 '22 at 16:12
  • Do you have a `Procfile`? That will take precedence over your `start` script if it exists. – ChrisGPT was on strike Jan 14 '22 at 16:14
  • I've tried Procfile as well and still the same error. Anyway, now I did my project again from the bottom, and now I don't use nodemon anymore. I don't have the nodemon error, but now I have a new one: "Warning: connect.session() MemoryStore is not designed for a production environment, as it will leak memory, and will not scale past a single process.". Anyway, thank you for your time and your answers, I will try to find help with the new error now... – Serb David Jan 15 '22 at 07:57

1 Answers1

0

Seems like you are using "nodemon". Probably if you installed with "npm i -g nodemon" you can see that error. So nodemon installed on your pc but your project have not nodemon. Just run npm i nodemon in your terminal while located project. Finally deploy again. And i'm sorry about bad english.

  • "Just run `npm i nodemon` in your terminal while located project"—that won't work on Heroku due to its ephemeral filesystem. All dependencies must be installed _at build time_. – ChrisGPT was on strike Jan 14 '22 at 13:33