Home > Blockchain >  Deploying node js app on heroku gives error
Deploying node js app on heroku gives error

Time:08-11

This is the log I get from running heroku logs --tail

2022-08-10T15:46:34.923072 00:00 heroku[web.1]: State changed from crashed to starting
2022-08-10T15:46:36.618392 00:00 heroku[web.1]: Starting process with command `npm start`
2022-08-10T15:46:38.505658 00:00 app[web.1]:
2022-08-10T15:46:38.505695 00:00 app[web.1]: > [email protected] start
2022-08-10T15:46:38.506098 00:00 app[web.1]: > index.js
2022-08-10T15:46:38.506098 00:00 app[web.1]:
2022-08-10T15:46:38.511467 00:00 app[web.1]: sh: 1: index.js: not found
2022-08-10T15:46:38.665217 00:00 heroku[web.1]: Process exited with status 127
2022-08-10T15:46:38.731469 00:00 heroku[web.1]: State changed from starting to crashed
2022-08-10T15:46:57.417977 00:00 app[api]: Stack changed from heroku-20 to heroku-22 by user [email protected]
2022-08-10T15:48:39.000000 00:00 app[api]: Build started by user [email protected]
2022-08-10T15:48:54.000000 00:00 app[api]: Build succeeded
2022-08-10T15:48:54.455105 00:00 app[api]: Deploy 75289dfb by user [email protected]
2022-08-10T15:48:54.455105 00:00 app[api]: Release v6 created by user [email protected]
2022-08-10T15:48:54.718566 00:00 heroku[web.1]: State changed from crashed to starting
2022-08-10T15:48:56.635960 00:00 heroku[web.1]: Starting process with command `npm start`
2022-08-10T15:48:59.157726 00:00 app[web.1]:
2022-08-10T15:48:59.157739 00:00 app[web.1]: > [email protected] start
2022-08-10T15:48:59.157739 00:00 app[web.1]: > index.js
2022-08-10T15:48:59.157740 00:00 app[web.1]:
2022-08-10T15:48:59.165066 00:00 app[web.1]: sh: 1: index.js: not found
2022-08-10T15:48:59.318731 00:00 heroku[web.1]: Process exited with status 127
2022-08-10T15:48:59.455664 00:00 heroku[web.1]: State changed from starting to crashed
2022-08-10T15:48:59.458782 00:00 heroku[web.1]: State changed from crashed to starting
2022-08-10T15:49:01.257931 00:00 heroku[web.1]: Starting process with command `npm start`
2022-08-10T15:49:03.132571 00:00 app[web.1]:
2022-08-10T15:49:03.132583 00:00 app[web.1]: > [email protected] start
2022-08-10T15:49:03.132583 00:00 app[web.1]: > index.js
2022-08-10T15:49:03.132583 00:00 app[web.1]:
2022-08-10T15:49:03.142956 00:00 app[web.1]: sh: 1: index.js: not found
2022-08-10T15:49:03.267249 00:00 heroku[web.1]: Process exited with status 127
2022-08-10T15:49:03.330712 00:00 heroku[web.1]: State changed from starting to crashed

As it says it seems that index.js is missing but I surely have it in the repo that I pushed... I don't know what's going on.

Update: so I logged in to heroku bash and uses ls command. It seems index.js is present.

~ $ ls
LICENSE  README.md  index.js  node_modules  package-lock.json  package.json  test.js

still giving that error though.

CodePudding user response:

Your start script needs to include the full command to run, not just the name of your main file:

"scripts": {
  "start": "node index.js"
}
  • Related