简体   繁体   English

Discord bot可以很好地在本地托管,但是如果我尝试将其托管在heroku上,它会显示“错误:找不到模块'discord.js'”

[英]Discord bot works fine hosted locally but if i try and host it on heroku it says “Error: Cannot find module 'discord.js'”

Discord bot works fine locally on discord server but when hosting on Heroku it says "Error: Cannot find module 'discord.js'" what can I do to fix this? Discord bot在Discord服务器上可以在本地正常运行,但是在Heroku上托管时会显示“错误:找不到模块'discord.js'”,我该怎么做才能解决此问题? (first time making a discord bot) (第一次制作不和谐的机器人)

I am not sure what to do to fix this so haven't tried anything other than checking the code 我不确定该如何解决,因此除了检查代码外没有尝试过其他任何方法

the code should be fine because it works on my discord server when I host it locally but all the code is posted here ( https://github.com/MathiasAC/team-skylo-discord-bot/tree/master/SkyloBotDiscord ) also, I have removed the bot token while I get help it's normally there 该代码应该很好,因为当我在本地托管它时,它可以在我的不和谐服务器上工作,但是所有代码也都发布在这里( https://github.com/MathiasAC/team-skylo-discord-bot/tree/master/SkyloBotDiscord ) ,我在获得帮助的同时删除了机器人令牌,通常该令牌在那

I expect it to be hosted on Heroku but it says "Error: Cannot find module 'discord.js'" even though discord.js in the bot folder and it works fine on my discord server locally hosted 我希望它可以托管在Heroku上,但是即使bot文件夹中的discord.js仍然显示“错误:找不到模块'discord.js'”,并且在本地托管的discord服务器上也可以正常工作

You don't have discord.js in your dependencies within package.json. package.json中的依赖项中没有discord.js。

Run: 跑:

npm install discord.js --save

Then push it to Heroku. 然后将其推到Heroku。

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

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