gpt4 book ai didi

javascript - Node.Js 14 版抛出 e;不和谐机器人的错误(discord.js)

转载 作者:行者123 更新时间:2023-12-04 12:53:31 31 4
gpt4 key购买 nike

我 fork 了一个 Discord music bot从 GitHub 到 ReplIt然后我尝试按照步骤成功运行机器人!
我使用 Node.JS v.14!
当我运行机器人时,我收到以下错误:

/home/runner/A-Advance-Discord-Music-Bot-Like-Hydra-/node_modules/bindings/bindings.js:121
throw e;
^

Error: The module '/home/runner/A-Advance-Discord-Music-Bot-Like-Hydra-/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 88. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1151:18)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at bindings (/home/runner/A-Advance-Discord-Music-Bot-Like-Hydra-/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/home/runner/A-Advance-Discord-Music-Bot-Like-Hydra-/node_modules/better-sqlite3/lib/database.js:9:24)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32) {
code: 'ERR_DLOPEN_FAILED'
}
exit status 1

这是我的 index.js文件:

//Importing all needed Commands
const Discord = require("discord.js"); //this is the official discord.js wrapper for the Discord Api, which we use!
const colors = require("colors"); //this Package is used, to change the colors of our Console! (optional and doesnt effect performance)
const Enmap = require("enmap"); //this package is our Database! We will use it to save the data for ever!
const fs = require("fs"); //this package is for reading files and getting their inputs

//Creating the Discord.js Client for This Bot with some default settings ;) and with partials, so you can fetch OLD messages
const client = new Discord.Client({
fetchAllMembers: false,
restTimeOffset: 0,
shards: "auto",
restWsBridgetimeout: 100,
disableEveryone: true,
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
intents: ["GUILDS", "GUILD_MESSAGES"]
});

require('events').EventEmitter.defaultMaxListeners = 100;
process.setMaxListeners(100);

//Loading files, with the client variable like Command Handler, Event Handler, ...
["clientvariables", "command", "events", "erelahandler", "requestreacts"].forEach(handler => {
require(`./handlers/${handler}`)(client);
});

//Each Database gets a own file and folder which is pretty handy!
client.premium = new Enmap({ name: "premium", dataDir: "./databases/premium" })
client.stats = new Enmap({ name: "stats", dataDir: "./databases/stats" })
client.settings = new Enmap({ name: "setups", dataDir: "./databases/settings" })
client.setups = new Enmap({ name: "setups", dataDir: "./databases/setups" })
client.queuesaves = new Enmap({ name: "queuesaves", dataDir: "./databases/queuesaves", ensureProps: false})
client.modActions = new Enmap({ name: 'actions', dataDir: "./databases/warns" });
client.userProfiles = new Enmap({ name: 'userProfiles', dataDir: "./databases/warns" });

//login into the bot
client.login(require("./botconfig/config.json").token);
谁能告诉我我的问题?
抱歉我的英语不好

最佳答案

为了修复这个错误,我们需要彻底修复我们的 npm 内存!

  • 第一步,我们需要删除node_modules:
    $ rm -rf node_modules package-lock.json
  • 然后清理我们的 npm 内存:
    $ npm cache clear --force$ npm cache clean --force
  • 并重新安装它以便它在新版本中编译!
    npm install

  • 我认为这可能会有所帮助!

    关于javascript - Node.Js 14 版抛出 e;不和谐机器人的错误(discord.js),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69333030/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com