node.js - 我如何获得由 discord bot 制造商创建的 Discord Bot 以在 Heroku 上工作
问题描述
因此,该机器人在本地运行时运行良好,但是当我在 heroku 上运行它时,它给了我一个错误消息:
2018-08-29T13:57:58.295022+00:00 app[web.1]: (node:4) ExperimentalWarning:
The http2 module is an experimental API.
2018-08-29T13:57:58.732365+00:00 app[web.1]: Bot is ready!
2018-08-29T13:58:55.278962+00:00 heroku[web.1]: Error R10 (Boot timeout) ->
Web process failed to bind to $PORT within 60 seconds of launch
2018-08-29T13:58:55.278962+00:00 heroku[web.1]: Stopping process with
SIGKILL
2018-08-29T13:58:55.404294+00:00 heroku[web.1]: Process exited with status 137
2018-08-29T13:58:55.623262+00:00 heroku[web.1]: State changed from starting to crashed
现在,如果我尝试那里的灵魂:
2018-08-29T14:07:46.618465+00:00 heroku[web.1]: Starting process with
command `node bot.js`
2018-08-29T14:07:48.107034+00:00 heroku[web.1]: Process exited with status 1
2018-08-29T14:07:48.063674+00:00 app[web.1]: /app/bot.js:8
2018-08-29T14:07:48.063700+00:00 app[web.1]: app.listen(PORT, () => {
2018-08-29T14:07:48.063701+00:00 app[web.1]: ^
2018-08-29T14:07:48.063703+00:00 app[web.1]:
2018-08-29T14:07:48.063704+00:00 app[web.1]: ReferenceError: app is not defined
2018-08-29T14:07:48.063706+00:00 app[web.1]: at Object.<anonymous>
(/app/bot.js:8:1)
2018-08-29T14:07:48.063707+00:00 app[web.1]: at Module._compile
(module.js:652:30)
2018-08-29T14:07:48.063709+00:00 app[web.1]: at
Object.Module._extensions..js (module.js:663:10)
2018-08-29T14:07:48.063711+00:00 app[web.1]: at Module.load
(module.js:565:32)
2018-08-29T14:07:48.063713+00:00 app[web.1]: at tryModuleLoad
(module.js:505:12)
2018-08-29T14:07:48.063714+00:00 app[web.1]: at Function.Module._load
(module.js:497:3)
2018-08-29T14:07:48.063716+00:00 app[web.1]: at Function.Module.runMain
(module.js:693:10)
2018-08-29T14:07:48.063718+00:00 app[web.1]: at startup
(bootstrap_node.js:191:16)
2018-08-29T14:07:48.063720+00:00 app[web.1]: at bootstrap_node.js:612:3
2018-08-29T14:07:48.120800+00:00 heroku[web.1]: State changed from starting
to crashed
还有我添加的脚本:https ://help.heroku.com/P1AVPANS/why-is-my-node-js-app-crashing-with-an-r10-error
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Our app is running on port ${ PORT }`);
});
解决方案
嗯...似乎错误是app
未定义的。
我假设您使用的是 JS Express 库,因此请确保正确安装了 Express 库。仔细检查您是否将其正确导入程序,并确保定义
const app = express();
推荐阅读
- docker - 无法通过 Digital Ocean 液滴在 Docker 上使用 Shiny 进行端口映射
- javascript - 如何使用原型访问字符串
- json - 如何在 json 值中添加前缀和属性?
- vuejs2 - 如何使 vuematerial 卡具有响应性
- jenkins - 在 Jenkins 中使用 pollSCM 和 Scan Multibranch Pipeline Triggers 有什么区别?
- sql - 使用 Sybase ASE 12.5.4 并查看列出/连接字符串值
- python - 避免转义不间断空格和 '<', '>'
- css - 如何在 Angular 中使用 ElementRef 访问 ::after 伪选择器
- java - 为什么 JAX-RS POST 不适用于多值映射
- vb.net - 如果组合框包含多个具有相同文本或不包含相同文本的项目,如何获取