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

JavaScript Error Call to 'require' failed: #143

Closed
HaiYTB opened this issue Jul 19, 2024 · 6 comments
Closed

JavaScript Error Call to 'require' failed: #143

HaiYTB opened this issue Jul 19, 2024 · 6 comments

Comments

@HaiYTB
Copy link

HaiYTB commented Jul 19, 2024

I can't require the mineflayer library. I use termux-monet latest version and python 3.11

☕  JavaScript Error  Call to 'require' failed:
> mineflayer = require("mineflayer")
  at <module> (/data/data/com.termux/files/home/minecraft-tool.py:13)
>

... across the bridge ...

  at defaultImportModuleDynamicallyForScript (node:internal/modules/esm/utils:227:31)
  at ModuleLoader.import (node:internal/modules/esm/loader:483:21)
  at TracingChannel.tracePromise (node:diagnostics_channel:337:14)
  at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:484:36)
  at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
  at ModuleLoader.resolve (node:internal/modules/esm/loader:526:25)
  at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
  at defaultResolve (node:internal/modules/esm/resolve:1132:11)
  at moduleResolve (node:internal/modules/esm/resolve:915:18)
  at packageResolve (node:internal/modules/esm/resolve:842:9)
  Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'mineflayer' imported from /data/data/com.termux/files/usr/lib/python3.11/site-packages/javascript/js/deps.js
> ^
🌉 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'mineflayer' imported from /data/data/com.termux/files/usr/lib/python3.11/site-packages/javascript/js/deps.js
import os
try:
    from javascript import require
except:
    os.system("pip install javascript")
    from javascript import require
try:
    os.system("node -v")
except:
    os.system("apt install node -y")
#try:
install("mineflayer")
mineflayer = require("mineflayer")
"""except:
    os.system("cd")
    os.system("npm install mineflayer")
    mineflayer = require("mineflayer")"""
os.system("clear")
class Bot:
    def __init__ (self, host_server_mc, port_server_mc):
        self.host_server_mc = host_server_mc
        self.port_server_mc = port_server_mc
    def joinbot(self):
        settings_bot_server_mc = {
            "host": self.host_server_mc,
            "port": self.port_server_mc,
            "username": "HaiYTB"
        }
        bot_server_mc = mineflayer.createBot(settings_bot_server_mc)
@HaiYTB
Copy link
Author

HaiYTB commented Jul 19, 2024

P/S: I am using NodeJS version v22.4.1

@rom1504
Copy link
Collaborator

rom1504 commented Jul 19, 2024 via email

@HaiYTB
Copy link
Author

HaiYTB commented Jul 20, 2024

Did you install mineflayer?

On Fri, Jul 19, 2024, 13:06 HaiYTB @.> wrote: P/S: I am using NodeJS version v22.4.1 — Reply to this email directly, view it on GitHub <#143 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437WRGDVFB7EFPXODRSLZNDXLJAVCNFSM6AAAAABLEL3BUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZYHEYTGMJXGU . You are receiving this because you are subscribed to this thread.Message ID: @.>

I have installed mineflayer

@extremeheat
Copy link
Owner

Run

python -m javascript --clean
python -m javascript --install mineflayer

And try again.

I recommend looking into testing with a google colab notebook first to try it out in a clean environment.

@HaiYTB
Copy link
Author

HaiYTB commented Jul 21, 2024

Tks ❤️ It worked

Run

python -m javascript --clean
python -m javascript --install mineflayer

And try again.

I recommend looking into testing with a google colab notebook first to try it out in a clean environment.

@askylift
Copy link

But I need to install the packages defined in my package.json
JSPyBridge can't find the installed node_modules in vercel
Here is the issue #145

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

4 participants