PythonMonkey icon indicating copy to clipboard operation
PythonMonkey copied to clipboard

NPM package requirement does not work on windows

Open OlivierPonant opened this issue 1 year ago • 5 comments

Issue type

Bug

How did you install PythonMonkey?

Installed from pip

OS platform and distribution

Windows 10

Python version (python --version)

3.10.2

PythonMonkey version (pip show pythonmonkey)

0.3.0

Bug Description

PythonMonkey is not able to require NPM package which requires another npm package.

Standalone code to reproduce the issue

It can be reproduce easily by launching the example on your repo : https://github.com/Distributive-Network/pythonmonkey-examples/tree/main/require-npm-package-from-py

Relevant log output or backtrace

(venv) PS C:\Users\olivierc\Documents\Repositories\pythonmonkey-examples> python .\require-npm-package-from-py\main.py
Traceback (most recent call last):
  File "C:\Users\olivierc\Documents\Repositories\pythonmonkey-examples\require-npm-package-from-py\main.py", line 11, in <module>
  File "C:\Users\olivierc\Documents\Repositories\pythonmonkey-examples\venv\lib\site-packages\pythonmonkey\require.py", line 353, in require
pythonmonkey.SpiderMonkeyError: Error in file C:\Users\olivierc\Documents\Repositories\pythonmonkey-examples\venv\lib\site-packages\pythonmonkey\node_modules/ctx-modError: module not found -- require('is-number') from C:/Users/olivierc/Documents/Repositories/pythonmonkey-examples/require-npm-package-from-py/node_modules/is-odd/index.js

Additional info if applicable

We tested it on 2 windows (10 and 11) and it does not work but on Linux Ubuntu, it worked like a charm !

What branch of PythonMonkey were you developing on? (If applicable)

No response

OlivierPonant avatar Feb 15 '24 12:02 OlivierPonant

@OlivierPonant , thanks for filing this issue - the PythonMonkey team will look into this


@philippedistributive @Xmader @caleb-distributive , here is the repro: https://github.com/Distributive-Network/pythonmonkey-examples/tree/main/require-npm-package-from-py <-- give it a shot on Windows

wiwichips avatar Feb 15 '24 12:02 wiwichips

This is likely a bug in the npm ctx-module package. I'm going to need to get access to a Windows box to debug this properly. Anybody have one I can SSH into? :)

wesgarland avatar Mar 09 '24 13:03 wesgarland

This is most likely issue #292

wesgarland avatar Mar 15 '24 11:03 wesgarland

I'm certain that this issue also exists in the latest release (0.9.0).

import pythonmonkey as pm

got error:

(venv) D:\workspace\tests\psd>d:/workspace/venv/Scripts/python.exe d:/workspace/tests/psd/test2.py
Traceback (most recent call last):
  File "d:\workspace\tests\psd\test2.py", line 1, in <module>
    import pythonmonkey as pm
  File "d:\workspace\venv\lib\site-packages\pythonmonkey\__init__.py", line 15, in <module>
    require("timers")
  File "d:\workspace\venv\lib\site-packages\pythonmonkey\require.py", line 429, in require
    return createRequire(filename)(moduleIdentifier)
pythonmonkey.SpiderMonkeyError: Error in file d:\workspace\venv\lib\site-packages\pythonmonkey\node_modules/ctx-module/ctx-module.js, on line 238, column 21:
Error: module not found -- require('d:/workspace/venv/lib/site-packages/pythonmonkey/node_modules/core-js/stable/dom-exception') from d:/workspace/venv/lib/site-packages/pythonmonkey/node_modules/core-js/actual/dom-exception/index.js
Stack Trace:
  ctxRequire@d:\workspace\venv\lib\site-packages\pythonmonkey\node_modules/ctx-module/ctx-module.js:122:7

Sun-ZhenXing avatar Sep 11 '24 06:09 Sun-ZhenXing

I created an issue dupe of this at #445 and it is fixed by https://github.com/wesgarland/ctx-module/pull/9

jacalata avatar Oct 03 '24 04:10 jacalata