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

require not definied. #462

Open
lkodotsrv opened this issue Dec 11, 2024 · 0 comments
Open

require not definied. #462

lkodotsrv opened this issue Dec 11, 2024 · 0 comments

Comments

@lkodotsrv
Copy link

Issue type

Bug

How did you install PythonMonkey?

Installed from pip

OS platform and distribution

Windows 10

Python version (python --version)

3.12.7

PythonMonkey version (pip show pythonmonkey)

1.1.0

Bug Description

When I require a module from a JS file or evaluation it will raise a ReferenceError

Standalone code to reproduce the issue

import pythonmonkey as pmjs
import os

def main() -> None:
    with open(os.path.join(os.getcwd(), 'myModule.js'), 'w') as f: f.write('function sqrt($){function r($){return $<0?-$:$}if($<0)return -1;let t=$/2,n;for(;!(1e-7>r((n=(t+$/t)/2)-t));)t=n;return n}exports.sqrt=sqrt;'); f.close() # JavaScript simple SQRT function
    pmjs.eval('''
const { sqrt } = require('./sqrt');
console.log(sqrt(230));
''')
    return 0
    
if __name__ == '__main__': main()

Relevant log output or backtrace

PS C:\Users\aleix\Desktop\Redleach> & C:/Users/aleix/AppData/Local/Programs/Python/Python312/python.exe c:/Users/aleix/Desktop/Redleach/test.py
Traceback (most recent call last):
  File "c:\Users\aleix\Desktop\Redleach\test.py", line 12, in <module>       
    if __name__ == '__main__': main()
                               ^^^^^^
  File "c:\Users\aleix\Desktop\Redleach\test.py", line 6, in main
    pmjs.eval('''
pythonmonkey.SpiderMonkeyError: Error in file evaluate, on line 2, column 18:
ReferenceError: require is not defined
Stack Trace:
  @evaluate:2:18

Additional info if applicable

No response

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

No response

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

No branches or pull requests

1 participant