简体   繁体   English

Discord.js 机器人的 Heroku 构建失败

[英]Heroku Build Failure for Discord.js bot

I have been coding a bot using discord.js, visual studio code, and node.js, and I have been trying to host it on Heroku.我一直在使用 discord.js、Visual Studio 代码和 node.js 编写一个机器人,我一直在尝试将它托管在 Heroku 上。 However, the log in my Heroku project claim that my build is failing, and it is giving the following message when I view the build log of the failure:但是,我的 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

Also, the more recent changes that I have made to my bot, like adding aliases to commands and changing the ping of my announce command, don't apply when I run the bot off of Heroku, but do work when I run the bot locally, and I think that the build failure may be the reason behind this.此外,我对我的机器人所做的最新更改,例如为命令添加别名和更改我的宣布命令的 ping,当我从 Heroku 运行机器人时不适用,但是当我在本地运行机器人时可以工作,我认为构建失败可能是这背后的原因。 I may be wrong, but I am still relatively new to coding Discord bots.我可能错了,但我对 Discord 机器人的编码还是比较陌生。 How can I fix the build failure?如何修复构建失败?

I've been searching for a solution to this problem all day.我整天都在寻找解决这个问题的方法。 I finally found it: While hosting your bot on heroku you can use " discord-music-player " instead of @discordjs/opus or opusscript.我终于找到了:在 heroku 上托管您的机器人时,您可以使用“ discord-music-player ”而不是@discordjs/opus 或 opusscript。 Tell me if it worked for you!告诉我它是否对你有用!

@discordjs/opus is not allowed on Heroku afaik.在 Heroku afaik 上不允许使用 @discordjs/opus。

Use opusscript instead if you really need to use music.如果您确实需要使用音乐,请改用 opusscript。

But as devs mentioned, @discordjs/opus is much better peformance wise so I recommend searching for another hosting solution if you want the audio streaming functionalities.但正如开发人员所提到的,@discordjs/opus 在性能方面要好得多,因此如果您想要音频流功能,我建议您搜索另一个托管解决方案。

Prebuild detected (node_modules already exists) you need to hide your node_modules using .gitignore in your folder project Prebuild detected (node_modules already exists)您需要在文件夹项目中使用.gitignore隐藏您的node_modules

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

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