你好,我正在尝试部署我的第一个机器人使用Heroku使用this教程。我已经设法把我的代码推到应用程序,但在添加我的config.json '令牌'到应用程序,并启动工人,我得到这个:
2022-10-23T04:55:31.815878+00:00 app[Worker.1]: Node.js v18.11.0
2022-10-23T04:55:31.927217+00:00 heroku[Worker.1]: Process exited with status 1
2022-10-23T04:55:31.983366+00:00 heroku[Worker.1]: State changed from up to crashed
2022-10-23T04:55:31.986264+00:00 heroku[Worker.1]: State changed from crashed to starting
2022-10-23T04:55:34.526205+00:00 heroku[Worker.1]: Starting process with command `node ./src/bot.js`
2022-10-23T04:55:35.356859+00:00 heroku[Worker.1]: State changed from starting to up
2022-10-23T04:55:36.599794+00:00 heroku[Worker.1]: Process exited with status 1
2022-10-23T04:55:36.413725+00:00 app[Worker.1]: node:internal/modules/cjs/loader:998
2022-10-23T04:55:36.413733+00:00 app[Worker.1]: throw err;
2022-10-23T04:55:36.413733+00:00 app[Worker.1]: ^
2022-10-23T04:55:36.413733+00:00 app[Worker.1]:
2022-10-23T04:55:36.413734+00:00 app[Worker.1]: Error: Cannot find module '/app/src/bot.js'
2022-10-23T04:55:36.413734+00:00 app[Worker.1]: at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
2022-10-23T04:55:36.413735+00:00 app[Worker.1]: at Module._load (node:internal/modules/cjs/loader:841:27)
2022-10-23T04:55:36.413735+00:00 app[Worker.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2022-10-23T04:55:36.413735+00:00 app[Worker.1]: at node:internal/main/run_main_module:23:47 {
2022-10-23T04:55:36.413748+00:00 app[Worker.1]: code: 'MODULE_NOT_FOUND',
2022-10-23T04:55:36.413749+00:00 app[Worker.1]: requireStack: []
2022-10-23T04:55:36.413749+00:00 app[Worker.1]: }
2022-10-23T04:55:36.413755+00:00 app[Worker.1]:
2022-10-23T04:55:36.413755+00:00 app[Worker.1]: Node.js v18.11.0
2022-10-23T04:55:36.653228+00:00 heroku[Worker.1]: State changed from up to crashed
我的package.json看起来像:
{
"name": "mudbot",
"version": "1.0.0",
"description": "MUDbot",
"main": "bot.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Shirish Sarkar",
"license": "ISC",
"dependencies": {
"discord.js": "^14.5.0",
"env": "^0.0.2"
}
}
我不明白是什么问题。任何帮助都是非常感谢的,谢谢。
编辑:这解决了我的问题:首先我的procfile指向了一个不正确的路径。然后我发现Heroku似乎只接受.env变量,而不是discord的bot指南上的默认配置config.json(他们应该改变这一点!)。在更新了这些东西并将变量添加到Heroku的配置后,bot就可以启动并运行了。
1条答案
按热度按时间qgelzfjb1#
这解决了我的问题:首先我的procfile指向了一个不正确的路径。然后我发现Heroku似乎只接受.env变量,而不是discord的bot指南上的默认配置config.json(他们应该改变这一点!)。在更新了这些东西并将变量添加到Heroku的配置后,bot就可以启动并运行了。