link-discord / mineflayer-auto-eat

Auto eat plugin for mineflayer
https://www.npmjs.com/package/mineflayer-auto-eat
MIT License
33 stars 4 forks source link

Mineflayer cannot load this plugin if it is installed with pnpm #28

Closed unclamped closed 1 year ago

unclamped commented 1 year ago

After doing some testing locally in my fork of 2bored2wait, and after trying to migrate from npm to pnpm, I found that this plugin would no longer be loaded by Mineflayer, and instead cause a crash. The crash originates on line 16 of Mineflayer's plugin loader, where it checks if the argument it has been passed (what should be the const of the required plugin) is a function or not: image If not, it fails. In the code, the plugin is imported with const autoeat = require("mineflayer-auto-eat").default;. Then, it tries to load that plugin and others, which is when it then calls the loadPlugin function that I talked about previously. image (in the screenshot it also shows a different plugin being loaded. I confirmed that it was auto-eat the one generating the issue, as shown in the following screenshot) image I tried looking at this plugin's code to see what the issue could be, but A- I am way too tired for today, and B- I didn't find anything obvious.

unclamped commented 1 year ago

turns out it was because there was a .default added in the end, when it should've been .plugin. I have no ideas as to why that happened, apologies

unclamped commented 1 year ago

wait actually, no, why would npm work with it but not pnpm, I'm rite

link-discord commented 1 year ago

Gonna check this sometime

link-discord commented 1 year ago

In my testing I was able to install & use mineflayer-auto-eat just fine with pnpm. Are you sure its not an error in the code you wrote?

link-discord commented 1 year ago

Will close this issue otherwise