简体   繁体   English

新的 discord.js 更新破坏了我的机器人 - heroku 未更新 node.js 版本以使 discordjs 工作

[英]New discord.js update broke my bot - heroku not updating node.js version to make discordjs work

I updated discord.js to v13 and doing that it won't start on Heroku and keeps crashing.我将 discord.js 更新到 v13,这样做不会在 Heroku 上启动并不断崩溃。 People have said It's because v13 discord.js requires node.js v16+, so I updated node and it doesn't work.人们说这是因为 v13 discord.js 需要 node.js v16+,所以我更新了节点,它不起作用。

In Heroku it still says v14在 Heroku 中仍然显示 v14

-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 14.x...
       Downloading and installing node 14.18.2...
       Using default npm version: 6.14.15

Here's the error I get in Heroku这是我在 Heroku 中遇到的错误

2021-12-13T07:01:30.774733+00:00 app[Worker.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2021-12-13T07:01:30.774751+00:00 app[Worker.1]:     agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2021-12-13T07:01:30.774752+00:00 app[Worker.1]:           ^^^
2021-12-13T07:01:30.774752+00:00 app[Worker.1]: 
2021-12-13T07:01:30.774753+00:00 app[Worker.1]: SyntaxError: Unexpected token '??='
2021-12-13T07:01:30.774753+00:00 app[Worker.1]:     at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2021-12-13T07:01:30.774753+00:00 app[Worker.1]:     at Module._compile (internal/modules/cjs/loader.js:1049:27)
2021-12-13T07:01:30.774754+00:00 app[Worker.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-12-13T07:01:30.774754+00:00 app[Worker.1]:     at Module.load (internal/modules/cjs/loader.js:950:32)
2021-12-13T07:01:30.774754+00:00 app[Worker.1]:     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2021-12-13T07:01:30.774755+00:00 app[Worker.1]:     at Module.require (internal/modules/cjs/loader.js:974:19)
2021-12-13T07:01:30.774755+00:00 app[Worker.1]:     at require (internal/modules/cjs/helpers.js:93:18)
2021-12-13T07:01:30.774755+00:00 app[Worker.1]:     at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:4:20)
2021-12-13T07:01:30.774755+00:00 app[Worker.1]:     at Module._compile (internal/modules/cjs/loader.js:1085:14)
2021-12-13T07:01:30.774756+00:00 app[Worker.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

I'm using github to update the bot through Heroku and I can't figure out how to tell Heroku I'm using node.js v16+. I'm using github to update the bot through Heroku and I can't figure out how to tell Heroku I'm using node.js v16+. If you need extra information let me know, thank you.如果您需要更多信息,请告诉我,谢谢。

You need to specify the node engine version in your package.json.您需要在 package.json 中指定节点引擎版本。 Add this to it and it should automatically use this version将其添加到它,它应该自动使用这个版本

"engines": {
    "node": "16.x"
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM