【问题标题】:Cannot host discord bot on Heroku无法在 Heroku 上托管不和谐机器人
【发布时间】:2022-01-03 09:59:39
【问题描述】:

我正在用 NodeJs 制作一个不和谐的音乐机器人,我一直在尝试在 Heroku 上托管它,但它总是因为这个问题而崩溃

 /app/node_modules/discord.js/src/rest/APIRequest.js:34
    agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
           ^^^
SyntaxError: Unexpected token '??='
     at wrapSafe (internal/modules/cjs/loader.js:1001:16)
     at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
     at Module.load (internal/modules/cjs/loader.js:950:32)
     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
   at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:5:20)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bee25@1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bee25@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-03T09:38:33.704796+00:00 app[Worker.1]: 
npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2022-01-03T09_38_33_700Z-debug.log
State changed from up to crashed
at=error code=H14 desc="No web processes running" method=GET path="/" host=bot-bee25.herokuapp.com request_id=e40f06e4-6d14-4cd4-ba4e-baa2091a87c9 fwd="216.245.221.84" dyno= connect= service= status=503 bytes= protocol=https

我该如何解决这个问题??

【问题讨论】:

标签: node.js heroku deployment build discord.js


【解决方案1】:

package.json 中添加以下代码行:

"engines": {
  "node": "16.x" //To get the latest node version
}

【讨论】:

    猜你喜欢
    • 2020-07-20
    • 2019-09-09
    • 2021-10-25
    • 2021-12-13
    • 2020-06-27
    • 2021-01-06
    • 2021-05-28
    • 2021-03-04
    • 2017-07-26
    相关资源
    最近更新 更多