Why does my Discord bot run in VS Code but not build on heroku.com
node.js 16.x
npm 8.4.0
It runs fine in Visual Studio Code, but when I try to run it through GitHub on heroku.com, I just get an incomprehensible error, which does not write the reason for the error.
I have updated all modules.
Please, help me!
package.json
"name": "isovbotik",
"version": "1.0.0",
"import": "node-fetch",
"engines": {
"node": "16.x",
"npm": "8.4.0"
},
"description": "GospodPojailusta3apustiBota",
"main": "bot.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "alexcitten",
"license": "ISC",
"dependencies": {
"@megavasiliy007/sdc-api": "github:MegaVasiliy007/sdc-api",
"amethyste-api": "^1.1.5",
"canvas": "^2.9.0",
"discord-buttons": "^4.0.0-deprecated",
"discord-slash-commands-client": "^1.2.2",
"discord-tictactoe": "^2.2.0",
"discord.js": "^12.4.1",
"discord.js-minesweeper": "^1.1.0",
"discordjs-mini-games": "^0.3.0",
"express": "^4.17.2",
"fs": "0.0.1-security",
"isgd": "^1.1.3",
"mal-scraper": "^2.11.4",
"moment": "^2.29.1",
"moment-duration-format": "^2.3.2",
"mongoose": "^5.10.16",
"ms": "^2.1.3",
"node-fetch": "^2.6.1",
"qr-image": "^3.2.0",
"request": "^2.88.2",
"rhyme": "^0.0.3",
"snekfetch": "^4.0.4",
"strftime": "^0.10.1",
"weather-js": "^2.0.0",
"zalgolize": "^1.2.4"
}
}
CodePudding user response:
"name": "isovbotik",
"version": "1.0.0",
"description": "GospodPojailusta3apustiBota",
"main": "bot.js",
"dependencies": {
"@megavasiliy007/sdc-api": "github:MegaVasiliy007/sdc-api",
"amethyste-api": "^1.1.5",
"canvas": "^2.9.0",
"discord-buttons": "^4.0.0-deprecated",
"discord-slash-commands-client": "^1.2.2",
"discord-tictactoe": "^2.2.0",
"discord.js": "^12.4.1",
"discord.js-minesweeper": "^1.1.0",
"discordjs-mini-games": "^0.3.0",
"express": "^4.17.2",
"fs": "0.0.1-security",
"isgd": "^1.1.3",
"mal-scraper": "^2.11.4",
"moment": "^2.29.1",
"moment-duration-format": "^2.3.2",
"mongoose": "^5.10.16",
"ms": "^2.1.3",
"node-fetch": "^2.6.1",
"qr-image": "^3.2.0",
"request": "^2.88.2",
"rhyme": "^0.0.3",
"snekfetch": "^4.0.4",
"strftime": "^0.10.1",
"weather-js": "^2.0.0",
"zalgolize": "^1.2.4"
},
"devDependencies": {},
"engines": {
"node": "16.x"
},
"scripts": {
"fs": "^0.0.1-security",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node bot.js"
},
"author": "alexcitten",
"license": "MIT"
}
and add Procfile
node: npm start
CodePudding user response:
First of all, you must add a start script into your package.json. This should look like:
.
.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node bot.js"
},
.
.
And as Fern said, you need to add a Procfile to your bot project for Heroku to recognize the process you're going to use.
The Procfile must be without an extension, and because your project is a Discord bot and you'll want it to be working continuously, you should use a worker.
So, your Procfile should look like this:
worker: node bot.js
Once you upload your project to Heroku, a new toggle called worker will appear into your project's Resources tab. You have to turn it on (and turn the web toggle off) to make your bot run continuously into Heroku.
