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

NPM package requirement does not work on windows #241

Open
OlivierPonant opened this issue Feb 15, 2024 · 5 comments
Open

NPM package requirement does not work on windows #241

OlivierPonant opened this issue Feb 15, 2024 · 5 comments

Comments

@OlivierPonant
Copy link

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

@wiwichips
Copy link
Collaborator

@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

@wesgarland
Copy link
Collaborator

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
Copy link
Collaborator

wesgarland commented Mar 15, 2024

This is most likely issue #292

@Sun-ZhenXing
Copy link

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

@jacalata
Copy link

jacalata commented Oct 3, 2024

I created an issue dupe of this at #445 and it is fixed by wesgarland/ctx-module#9

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

No branches or pull requests

5 participants