簡體   English   中英

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

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

我將 discord.js 更新到 v13,這樣做不會在 Heroku 上啟動並不斷崩潰。 人們說這是因為 v13 discord.js 需要 node.js v16+,所以我更新了節點,它不起作用。

在 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

這是我在 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+. 如果您需要更多信息,請告訴我,謝謝。

您需要在 package.json 中指定節點引擎版本。 將其添加到它,它應該自動使用這個版本

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM