Home > Mobile >  Heroku Node.js Discord Bot not starting
Heroku Node.js Discord Bot not starting

Time:11-17

I am currently facing an issue where my Discord Node.js bot is not starting on Heroku for some reason, despite doing everything that I could possibly find on this forum, the official documentation, youtube videos, anything.

If I run the index.js file on my computer, the bot successfully logs in, and commands I have added so far work perfectly fine. But of course I want to offload this payload to a server, that is Heroku.

My project is on a private repository on GitHub, with which I have already set up auto deploy on the Heroku dashboard (main branch).

My folder structure:

node_modules/
src/
   Commands/
   Data/
   Events/
   Structures/
   index.js
.gitignore
package-lock.json
package.json
Procfile
README.md

The content of my Procfile is this (without quotes): "worker: node src/index.js"
In package.json, relevant parts are:

"main": "src/index.js",
"scripts": {
   "start": "node src/index.js"
},
"engines": {
   "node": "16.x",
   "npm": "8.x"
},
"repository": {
   "type": "git",
   "url": "git https://github.com/******/******.git"
},
"private": true

Environmental variables are also set up on the Heroku Dashboard, and it is on the gitignore list, and found at src/Data/config.json file.

I have checked the Heroku logs, and it's literally empty. It didn't even try to start yet, and on the Resources tab of the dashboard, it says "This app has no process types yet. Add a Procfile to to your app in order to define it's process types." However, I totally have a Procfile in the folder, and on GitHub as well.
I also added the Node.js Buildpack to my app on the Heroku Dashboard.

Guys, what am I missing here? How could I finally get Heroku to launch my Node.js?
I'm gonna close this help request by a quote from one of my favorite games (We Were Here Together): "Please somebody help!" :)

CodePudding user response:

Okay, figured it out. For someone in the future that runs into the same issue:

Solution was to disconnect, then reconnect the GitHub repository on the Heroku Dashboard.

Users must have a Procfile described in the question, where the js file points to the index file, with directory relative reference. package.json must contain the start script. Version number declaration is not mandatory.

  • Related