Search code examples
javascriptnode.jsexpressherokunpm

Node.js app not deploying correctly on Heroku


My repository: https://github.com/jacklemasters/tech-blog

The app works locally on my machine, but I cannot seem to figure out why it will not work on Heroku. I have attempted completely moving the code, a new repository, nothing seems to help.

Here are the error logs I am receiving from Heroku: 2021-10-04T14:32:52.833339+00:00 app[web.1]: npm ERR! [email protected] start: node server.js 2021-10-04T14:32:52.833414+00:00 app[web.1]: npm ERR! Exit status 1 2021-10-04T14:32:52.833484+00:00 app[web.1]: npm ERR! 2021-10-04T14:32:52.833533+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script. 2021-10-04T14:32:52.833601+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2021-10-04T14:32:52.847732+00:00 app[web.1]: 2021-10-04T14:32:52.847831+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2021-10-04T14:32:52.847916+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-10-04T14_32_52_834Z-debug.log 2021-10-04T14:32:53.006395+00:00 heroku[web.1]: Process exited with status 1 2021-10-04T14:32:53.089213+00:00 heroku[web.1]: State changed from starting to crashed

edit: I understand it could be something with my packages, but on my side I see them as installed. Still at a loss!


Solution

  • You are using libraries that you didn't import into the package.json with npm.

    Example: npm install express-session

    Other thing that is wrong is to upload the .dotenv file to GitHub. Use the .gitignore to avoid it and configure the heroku envorinment variables. See more here: https://devcenter.heroku.com/articles/config-vars