Home > Software design >  Node.Js version 14 throw e; error for discord bots (discord.js)
Node.Js version 14 throw e; error for discord bots (discord.js)

Time:09-27

I forked a Discord music bot from GitHub to ReplIt and then I try to follow steps to run the bot successfully!

I use Node.JS v.14!

When I run the bot I receive following error:

/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

And here is my index.js file:


//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);

Can anyone tell me my problem?

Sorry for my bad English

CodePudding user response:

You would have to force clean your npm cache and remove your node_modules and reinstall them again to compile them against a new node version, for the same you may use the following commands in your Console / Shell:

rm -rf node_modules && rm package-lock.json && npm cache clear --force && npm cache clean --force && npm install

CodePudding user response:

Seems you updated the Node.js version, you can use npm rebuild to rebuild to the new version of Node.js then start the application, use only once the command not every time you start the applicatoin

  • Related