Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node.js install error #179

Open
fangd123 opened this issue Nov 18, 2024 · 10 comments
Open

node.js install error #179

fangd123 opened this issue Nov 18, 2024 · 10 comments

Comments

@fangd123
Copy link

when I ran the command

cd mineflayer-collectblock
npx tsc

I got the errors as follow:

src/CollectBlock.ts:71:59 - error TS2538: Type 'undefined' cannot be used as an index type.

71                                 bot.registry.blocksByName[closest.name];
                                                             ~~~~~~~~~~~~

src/CollectBlock.ts:75:61 - error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.

75                             const item = bot.registry.items[leastTool];
                                                               ~~~~~~~~~


Found 2 errors in the same file, starting at: src/CollectBlock.ts:71

I use node v22.11.0 and v18.20

@lplombos
Copy link

I have the exact same issue. Does anyone know how to solve it?

@electronic-pig
Copy link

same error...

@djbrown79
Copy link

I'm just bumping this. Same issue.

@Southmelon-Allen
Copy link

Met problem when running this:

cd mineflayer-collectblock
npx tsc

error as below:

(node:44262) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created)
(node:44262) [DEP0060] DeprecationWarning: The util._extend API is deprecated. Please use Object.assign() instead.
npm ERR! cb.apply is not a function

@djbrown79
Copy link

I (think) I found the problem.

You need to change the following in voyager\env\mineflayer\mineflayer-collectblock\src\BlockVeins.ts:

from:
import { Block } from 'prismarine-block'

to:
import { Block } from 'mineflayer/node_modules/prismarine-block'

@Marrbless
Copy link

`(voyager) gulper@gulper-OptiPlex-7040:~/Agent/Voyager/voyager/env/mineflayer/mineflayer-collectblock$ sudo npx tsc
src/CollectBlock.ts:71:59 - error TS2538: Type 'undefined' cannot be used as an index type.

71 bot.registry.blocksByName[closest.name];
~~~~~~~~~~~~

src/CollectBlock.ts:75:61 - error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.

75 const item = bot.registry.items[leastTool];
~~~~~~~~~

Found 2 errors in the same file, starting at: src/CollectBlock.ts:71`

ive tried node 18.19.1 and 16.13.0
i used #179 (comment) 's tip in both BlockVeins.ts and CollectBlock.ts but changing the path to prismarine-block did not fix anything.

ive deleted and redownloaded prismarine-block versions. i changed the versions in package.json in voyager/emv/mineflayer to =1.16.3 and ^1.17.1 which neither worked

ive used java versions 8, 11, 17, and 21 with none of them changing anything

@djbrown79
Copy link

djbrown79 commented Dec 11, 2024 via email

@djbrown79
Copy link

I created a fork with the code fixes and created an installer. The caveat is that it's Windows only. I decided not to PR into this repo because of that. However, if the creators would like to take my changes in whole or in part, that's completely fine. Here's the repo:

https://github.com/djbrown79/Voyager
See updated installation instructions in README.md.

note: I only have my home machine to test on, so if it doesn't work for you just submit a bug. Also, let me know if any part of the instructions are unclear or incorrect.

@rowingchenn
Copy link

I (think) I found the problem.

You need to change the following in voyager\env\mineflayer\mineflayer-collectblock\src\BlockVeins.ts:

from: import { Block } from 'prismarine-block'

to: import { Block } from 'mineflayer/node_modules/prismarine-block'

have you solved it? I tried but didn't help

@hehesangsj
Copy link

change voyager/env/mineflayer/mineflayer-collectblock/src/CollectBlock.ts line 70-77 should fix it:
From:

                            const properties =
                                bot.registry.blocksByName[closest.name];
                            const leastTool = Object.keys(
                                properties.harvestTools
                            )[0];
                            const item = bot.registry.items[leastTool];

To:

                            const properties =
                                bot.registry.blocksByName[closest.name as string];
                            const leastTool = Object.keys(
                                // @ts-ignore
                                properties.harvestTools
                            )[0];
                            // @ts-ignore
                            const item = bot.registry.items[leastTool]

Thanks to @djbrown79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants