MineDojo / Voyager

An Open-Ended Embodied Agent with Large Language Models
https://voyager.minedojo.org/
MIT License
5.36k stars 492 forks source link

npx tsc failed #105

Closed dongyh20 closed 1 year ago

dongyh20 commented 1 year ago

I'm trying to install the Node.js packages.

cd voyager/env/mineflayer
npm install -g npx
npm install

These steps work well, however, when I ran the command:

cd mineflayer-collectblock
npx tsc

I got some errors:

src/BlockVeins.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from 'prismarine-block'
           ~~~~~

src/CollectBlock.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from "prismarine-block";
           ~~~~~

src/CollectBlock.ts:186:9 - error TS2578: Unused '@ts-expect-error' directive.

186         // @ts-expect-error
            ~~~~~~~~~~~~~~~~~~~

src/Targets.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from 'prismarine-block'
           ~~~~~

Found 4 errors in 3 files.

Errors  Files
     1  src/BlockVeins.ts:2
     2  src/CollectBlock.ts:2
     1  src/Targets.ts:2

I further go into details and find the Block in prismarine-block in voyager/env/mineflayer/mineflayer-collectblock/node_modules/prismarine-block/example.js:

const registry = require('prismarine-registry')('1.8')
const Block = require('prismarine-block')(registry)

but I have no idea why it didn't work.

dongyh20 commented 1 year ago

I use the 18.16.1 version of Node.js.

ShaoTengLiu commented 1 year ago

You can try to follow this solution: https://stackoverflow.com/questions/63429304/npm-err-cb-apply-is-not-a-function

In my case, I succeed by deleting the node_modules and reinstalling.

dongyh20 commented 1 year ago

You can try to follow this solution: https://stackoverflow.com/questions/63429304/npm-err-cb-apply-is-not-a-function

In my case, I succeed by deleting the node_modules and reinstalling.

Not work for me. In my case, it seems that the Block module is not exported correctly.

dongyh20 commented 1 year ago

I also tried to use the version of 16.13.0, still got the same error. I also tried the solutiom described in #66 , still got the same error. I'm wondering has anyone encountered the same issue?

FrostQueenMaya commented 1 year ago

I have encountered the same issue stated above, here is my output in console:

C:\Users\Shadow\Documents\Voyager\Voyager\voyager\env\mineflayer\mineflayer-collectblock>npx tsc
src/BlockVeins.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from 'prismarine-block'
           ~~~~~

src/CollectBlock.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from "prismarine-block";
           ~~~~~

src/CollectBlock.ts:186:9 - error TS2578: Unused '@ts-expect-error' directive.

186         // @ts-expect-error
            ~~~~~~~~~~~~~~~~~~~

src/Targets.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from 'prismarine-block'
           ~~~~~

Found 4 errors in 3 files.

Errors  Files
     1  src/BlockVeins.ts:2
     2  src/CollectBlock.ts:2
     1  src/Targets.ts:2

I am using the correct version of NodeJS and python 3.10 could my python version be the issue?

EDIT: After downgrading python the issue persists.

OrilinZ commented 1 year ago

I do have the same problem: with python 3.9, NodeJS v18.16.1, npm 9.5.1.

src/BlockVeins.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from 'prismarine-block'
           ~~~~~

src/CollectBlock.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from "prismarine-block";
           ~~~~~

src/CollectBlock.ts:186:9 - error TS2578: Unused '@ts-expect-error' directive.

186         // @ts-expect-error
            ~~~~~~~~~~~~~~~~~~~

src/Targets.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from 'prismarine-block'
           ~~~~~

Found 4 errors in 3 files.

Errors  Files
     1  src/BlockVeins.ts:2
     2  src/CollectBlock.ts:2
     1  src/Targets.ts:2

When I want to upgrade npm. sudo npm install -g npm@latest. I found "node":"10.19.0","npm":"6.14.4", but why? when I node -v and npm -v, I got the version is v18.16.1 and 9.5.1.

npm WARN notsup Unsupported engine for npm@9.7.2: wanted: {"node":"^14.17.0 || ^16.13.0 || >=18.0.0"} (current: {"node":"10.19.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: npm@9.7.2

npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/npm/bin/npm-cli.js
npm ERR! dest /usr/local/bin/npm
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/npm/bin/npm-cli.js' -> '/usr/local/bin/npm'
npm ERR! File exists: /usr/local/bin/npm
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-07-04T14_45_47_715Z-debug.log
dongyh20 commented 1 year ago

I do have the same problem: with python 3.9, NodeJS v18.16.1, npm 9.5.1.

src/BlockVeins.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from 'prismarine-block'
           ~~~~~

src/CollectBlock.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from "prismarine-block";
           ~~~~~

src/CollectBlock.ts:186:9 - error TS2578: Unused '@ts-expect-error' directive.

186         // @ts-expect-error
            ~~~~~~~~~~~~~~~~~~~

src/Targets.ts:2:10 - error TS2305: Module '"prismarine-block"' has no exported member 'Block'.

2 import { Block } from 'prismarine-block'
           ~~~~~

Found 4 errors in 3 files.

Errors  Files
     1  src/BlockVeins.ts:2
     2  src/CollectBlock.ts:2
     1  src/Targets.ts:2

When I want to upgrade npm. sudo npm install -g npm@latest. I found "node":"10.19.0","npm":"6.14.4", but why? when I node -v and npm -v, I got the version is v18.16.1 and 9.5.1.

npm WARN notsup Unsupported engine for npm@9.7.2: wanted: {"node":"^14.17.0 || ^16.13.0 || >=18.0.0"} (current: {"node":"10.19.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: npm@9.7.2

npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/npm/bin/npm-cli.js
npm ERR! dest /usr/local/bin/npm
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/npm/bin/npm-cli.js' -> '/usr/local/bin/npm'
npm ERR! File exists: /usr/local/bin/npm
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-07-04T14_45_47_715Z-debug.log

Seems sudo will automatically install the version you mentioned above (at least in my case it works like this.)

dongyh20 commented 1 year ago

It seems others have also encountered the same issue and the instruction not works for everyone. Is there a possible solution?

khiempham06 commented 1 year ago

try downgrade prismarine-block npm uninstall prismarine-block npm install prismarine-block@1.16.3 it works for me.

dongyh20 commented 1 year ago

try downgrade prismarine-block npm uninstall prismarine-block npm install prismarine-block@1.16.3 it works for me.

Thanks! At least it works for me! There isn't any errors now and I've check the Block now works well. I'll go on to finish the rest of the environment to verify if it is installed correctly asap.

dongyh20 commented 1 year ago

Finally it worked.