extremeheat / JSPyBridge

πŸŒ‰. Bridge to interoperate Node.js and Python
MIT License
681 stars 49 forks source link

JavaScript Error Call to 'require' failed: #143

Closed HaiYTB closed 3 weeks ago

HaiYTB commented 2 months ago

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 commented 2 months ago

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

rom1504 commented 2 months ago

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 https://github.com/extremeheat/JSPyBridge/issues/143#issuecomment-2238913175, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437WRGDVFB7EFPXODRSLZNDXLJAVCNFSM6AAAAABLEL3BUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZYHEYTGMJXGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

HaiYTB commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 3 weeks ago

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