Search code examples
node.jsherokunpm

Node.js Heroku process crashes


I'm trying to use heroku.com hosting for host a discord bot So I tried to start the deployment and got no errors,

but if i go into the console i have this:

2021-09-06T14: 22: 20.024343 + 00: 00 heroku [web.1]: Process exited with status 1 2021-09-06T14: 22: 20.283616 + 00: 00 heroku [web.1]: State changed from starting to crashed 2021-09-06T14: 22: 20.288059 + 00: 00 heroku [web.1]: State changed from crashed to starting 2021-09-06T14: 22: 24.651531 + 00: 00 heroku [web.1]: Starting process with command npm start 2021-09-06T14: 22: 27.056803 + 00: 00 app [web.1]: npm ERR! missing script: start 2021-09-06T14: 22: 27.063092 + 00: 00 app [web.1]: 2021-09-06T14: 22: 27.063269 + 00: 00 app [web.1]: npm ERR! A complete log of this run can be found in: 2021-09-06T14: 22: 27.063325 + 00: 00 app [web.1]: npm ERR! /app/.npm/_logs/2021-09-06T14_22_27_057Z-debug.log 2021-09-06T14: 22: 27.112489 + 00: 00 heroku [web.1]: Process exited with status 1 2021-09-06T14: 22: 27.182105 + 00: 00 heroku [web.1]: State changed from starting to crashed

So, the process crashed, in fact if I try to go here-> https://bouncerbotds.herokuapp.com I get an error. I honestly don't understand why since everything works correctly in my machine when I go to: node . with the same project.

Anyone know how I could solve?


Solution

  • The error is super clear! You're missing a start script in your package.json, you might have initialised the deploy command as npm start in your Heroku Procfile although for it to run something it needs a default script which we call start, you may add it like this:

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

    You may look at npm documentation for understanding it better!