PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.91k stars 902 forks source link

Warning: Accessing non-existent property 'toJSON' of module exports inside circular dependency #2037

Closed ProfessorQu closed 3 years ago

ProfessorQu commented 3 years ago

Versions

Detailed description of a problem

Everytime I try and start my bot it gives this error:

(node:14536) Warning: Accessing non-existent property 'toJSON' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

What did you try yet?

I tried removing/commenting out code that I added. I tried removing package.json and package-lock.json and reinstalling mineflayer and the plugins,

Your current code

const mineflayer = require("mineflayer");
const pvp = require("mineflayer-pvp").plugin;
const minecraftHawkEye = require("minecrafthawkeye");
const { pathfinder, Movements, goals } = require("mineflayer-pathfinder");
const armorManager = require("mineflayer-armor-manager");
const collectBlock = require("mineflayer-collectblock").plugin;

// Create the bot
const bot = mineflayer.createBot({
  host: "localhost",
  port: process.argv[2],
  version: "1.16.5",
  username: "TotallyNotABot",
});

// Load plugins
bot.loadPlugin(pvp);
bot.loadPlugin(minecraftHawkEye);
bot.loadPlugin(pathfinder);
bot.loadPlugin(armorManager);
bot.loadPlugin(collectBlock);

// Set mcData and movements
let mcData;
let movements;

bot.once("spawn", () => {
  mcData = require("minecraft-data")(bot.version);
  movements = new Movements(bot, mcData);
  bot.pathfinder.setMovements(movements);
});

Expected behavior

The bot joins the server and nothing else happens

u9g commented 3 years ago
  1. not an error, its a warning
  2. this is fue to one of the plugins you installed, not mineflayer itself
ProfessorQu commented 3 years ago

I fixed it by deleting the entire node_modules file and reinstalling every package