【问题标题】:Heroku Build Failure for Discord.js botDiscord.js 机器人的 Heroku 构建失败
【发布时间】:2021-07-14 00:59:09
【问题描述】:

我一直在使用 discord.js、visual studio code 和 node.js 编写一个机器人,并且我一直在尝试将它托管在 Heroku 上。但是,我的 Heroku 项目中的日志声称我的构建失败,当我查看失败的构建日志时,它给出了以下消息:

-----> Installing dependencies
       Prebuild detected (node_modules already exists)
       Rebuilding any native modules
       
       > @discordjs/opus@0.5.0 install /tmp/build_0229f43f/node_modules/@discordjs/opus
       > node-pre-gyp install --fallback-to-build
       
       sh: 1: node-pre-gyp: Permission denied
       npm ERR! code ELIFECYCLE
       npm ERR! errno 126
       npm ERR! @discordjs/opus@0.5.0 install: `node-pre-gyp install --fallback-to-build`
       npm ERR! Exit status 126
       npm ERR! 
       npm ERR! Failed at the @discordjs/opus@0.5.0 install script.
       npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.q9Do7/_logs/2021-04-19T19_49_08_993Z-debug.log
-----> Build failed

此外,我对我的机器人所做的最新更改,例如为命令添加别名和更改我的宣布命令的 ping,在我从 Heroku 运行机器人时不适用,但在我运行时确实有效机器人本地,我认为构建失败可能是这背后的原因。我可能错了,但我对 Discord 机器人的编码还是比较陌生。如何修复构建失败?

【问题讨论】:

    标签: node.js heroku visual-studio-code discord.js


    【解决方案1】:

    Heroku afaik 上不允许使用@discordjs/opus。

    如果您真的需要使用音乐,请改用 opusscript。

    但正如开发人员所提到的,@discordjs/opus 在性能方面要好得多,因此如果您需要音频流功能,我建议您搜索其他托管解决方案。

    【讨论】:

      【解决方案2】:

      我整天都在寻找解决这个问题的方法。 我终于找到了: 在 heroku 上托管您的机器人时,您可以使用“discord-music-player”而不是 @discordjs/opus 或 opusscript。 告诉我它是否适合你!

      【讨论】:

        【解决方案3】:

        Prebuild detected (node_modules already exists) 您需要在文件夹项目中使用.gitignore 隐藏您的node_modules

        【讨论】:

          猜你喜欢
          • 2019-02-16
          • 2021-11-10
          • 2021-07-15
          • 2021-07-11
          • 2020-06-27
          • 2021-08-17
          • 2021-01-20
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多