[英]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:可能的问题是:
node_modules
folder.他们将您的需求重新路由到他们的服务器,而不是独立拥有一个node_modules
文件夹。npm
, but pnpm
, having both at once tend to not work, use pnpm
instead.他们不使用npm
,而是使用pnpm
,同时使用两者往往不起作用,而是使用pnpm
。index.js
is).您没有在主文件夹( index.js
所在的位置)中安装模块。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.