简体   繁体   English

错误:在线主机上找不到模块“discord.js”

[英]Error: Cannot find module 'discord.js' on online host

Today I uploading my discord bot to an online host.今天我将我的 discord 机器人上传到在线主机。 I Installed on my files on to the ftp with out any errors.我将我的文件安装到 ftp 上,没有任何错误。 The host is Pebble Host.主机是 Pebble Host。 When Tried to Start the bot I got the error bellow.当尝试启动机器人时,出现以下错误。 I tried starting the bot on my computer and it worked completely fine.我试着在我的电脑上启动机器人,它运行得很好。 I also installed all the modules.我还安装了所有模块。 If you can help me that would be great.如果你能帮助我,那就太好了。 Thanks!谢谢!

01.09 21:00:30 [Bot] internal/modules/cjs/loader.js:960
01.09 21:00:30 [Bot] throw err;
01.09 21:00:30 [Bot] ^
01.09 21:00:30 [Bot] Error: Cannot find module 'discord.js'
01.09 21:00:30 [Bot] Require stack:
01.09 21:00:30 [Bot] - /index.js
01.09 21:00:30 [Bot] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
01.09 21:00:30 [Bot] at Function.Module._load (internal/modules/cjs/loader.js:840:27)
01.09 21:00:30 [Bot] at Module.require (internal/modules/cjs/loader.js:1019:19)
01.09 21:00:30 [Bot] at require (internal/modules/cjs/helpers.js:77:18)
01.09 21:00:30 [Bot] at Object.<anonymous> (/index.js:2:17)
01.09 21:00:30 [Bot] at Module._compile (internal/modules/cjs/loader.js:1133:30)
01.09 21:00:30 [Bot] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
01.09 21:00:30 [Bot] at Module.load (internal/modules/cjs/loader.js:977:32)
01.09 21:00:30 [Bot] at Function.Module._load (internal/modules/cjs/loader.js:877:14)
01.09 21:00:30 [Bot] at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
01.09 21:00:30 [Bot] code: 'MODULE_NOT_FOUND',
01.09 21:00:30 [Bot] requireStack: [ '/index.js' ]
01.09 21:00:30 [Bot] }

Try going to your package.json and in the dependencies section, add "discord.js": "^12.3.0" and every other packages you need.尝试转到您的package.json并在依赖项部分添加"discord.js": "^12.3.0"和您需要的所有其他包。 Then go to the terminal / console and type然后 go 到终端/控制台并输入

npm install

While you're in the directory where your index.js file is located.当您位于index.js文件所在的目录中时。 This should fix the issue.这应该可以解决问题。 Sometimes online hosts tend to have some issues with the npm installation, and they check your package.json rather than saving what you previously installed.有时在线主机往往会出现 npm 安装问题,他们会检查您的package.json而不是保存您之前安装的内容。
The possible issues are:可能的问题是:

  1. They reroute your require to their server rather than independently having a node_modules folder.他们将您的需求重新路由到他们的服务器,而不是独立拥有一个node_modules文件夹。
  2. You didn't install it properly.你没有正确安装它。
  3. They don't use npm , but pnpm , having both at once tend to not work, use pnpm instead.他们不使用npm ,而是使用pnpm ,同时使用两者往往不起作用,而是使用pnpm
  4. You didn't install the modules in your main folder (where your index.js is).您没有在主文件夹( index.js所在的位置)中安装模块。
  5. The host has some internal issues with their server and are unable to install the modules properly.主机的服务器存在一些内部问题,无法正确安装模块。

Idk if still relevant but you need to run "npm install discord.js" from cmd https://discord.js.org/#/ (thought was important as is the top link on google search) Idk 如果仍然相关,但你需要从 cmd https://discord.js.org/#/运行“npm install discord.js”(认为很重要,谷歌搜索的顶部链接也是如此)

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

相关问题 Discord bot可以很好地在本地托管,但是如果我尝试将其托管在heroku上,它会显示“错误:找不到模块&#39;discord.js&#39;” - Discord bot works fine hosted locally but if i try and host it on heroku it says “Error: Cannot find module 'discord.js'” 使用 Discord.js 时出现“错误:找不到模块” - “Error: Cannot find module” While Using Discord.js 找不到模块'discord.js' - Cannot find module 'discord.js' 找不到模块“令牌”discord.js - cannot find module “token” discord.js discord.js 中的机器人运行错误(错误:找不到模块/代码:'MODULE_NOT_FOUND',requireStack:[]) - Bot running error in discord.js (Error: Cannot find module / code: 'MODULE_NOT_FOUND', requireStack: []) 制作 Discord.js 机器人时出现错误“错误:找不到模块‘随机’” - I am having an error “Error: Cannot find module 'random'” while making a Discord.js bot 找不到模块“discord.js”,控制台报告 - Cannot find module 'discord.js', console reporting Discord.js:错误:更新到 v13 后“找不到模块‘node:events’” - Discord.js: Error: "Cannot find module 'node:events'" after updating to v13 当 Discord.js 在 mySQL 的数组中找不到项目时出错 - Error when Discord.js cannot find an item in an array with mySQL 无法找到节点:使用 discord.js 的事件 - Cannot Find Node:Events with discord.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM