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

Cannot find module 'https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.asm.js' #4174

Closed
BiTronicsDev opened this issue Sep 25, 2023 · 6 comments · Fixed by #4294
Closed

Cannot find module 'https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.asm.js' #4174

BiTronicsDev opened this issue Sep 25, 2023 · 6 comments · Fixed by #4294
Labels
bug Something isn't working
Milestone

Comments

@BiTronicsDev
Copy link

BiTronicsDev commented Sep 25, 2023

Hi all. I have the following problem: I'm trying to use pyodide in a react. I installed the package using npm install, and imported the loadPyodide function from it. I have this code:

const pyodide = await loadPyodide({
             indexURL: "https://cdn.jsdelivr.net/pyodide/v0.24.0/full/",
             fullStdLib: true,
             stdin: window.prompt,
             stdout: (text) => {
                 if (text !== "Python initialization complete") {
                     setResult(prevState => prevState + text + "\n")
                 }
             },
             stderr: (text) => {
                 setResult(prevState => prevState + text + "\n")
             }
         });

However I get an error:

Cannot find module 'https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.asm.js'
     at http://localhost:3000/static/js/bundle.js:277779:11
     at async loadScript (http://localhost:3000/static/js/bundle.js:317327:43)
     at async loadPyodide (http://localhost:3000/static/js/bundle.js:317657:5)
     at async loadPython (http://localhost:3000/static/js/bundle.js:41685:21)
     at async run (http://localhost:3000/static/js/bundle.js:41761:24)

How can you solve it? I would appreciate your answer.

@BiTronicsDev BiTronicsDev added the bug Something isn't working label Sep 25, 2023
@ryanking13
Copy link
Member

Thanks for the report @BiTronicsDev. It is strange that the module tries to load Pyodide from the dev branch, not the v0.24.0 version you provided...

Could you share us a full and minimum code that we can reproduce?

@tylfin
Copy link

tylfin commented Sep 30, 2023

I have the same issue when I try to upgrade to v0.24.*, using indexURL in the same manner:

https://github.com/tylfin/restructedpyjs/blob/186bf34ba5212c74d0825799a6ce156e58fdfc3a/src/restructedpyjs.js#L19-L24

The error stack I'm getting looks like:

Uncaught (in promise) Error: Cannot find module 'https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.asm.js'
    ./node_modules/pyodide lazy recursive/t/< lazy strict namespace object:5
    promise callback*t lazy strict namespace object:4
    ...

This branch has the error: tylfin/restructedpyjs#38

@rth rth added this to the 0.24.2 milestone Oct 2, 2023
@rth
Copy link
Member

rth commented Oct 2, 2023

Possibly due to changes in #3967

installed the package using npm install, and imported the loadPyodide function from it

If you installed it via npm, indexURL is expected to be a local folder, I think. Or just don't pass that parameter, and it will use the version you installed. The default is to take artifacts from the node_modules which has all files necessary to load Pyodide. We should update the readme of the npm package.

Same comment for @tylfin, removing the indexURL argument from your code should fix it.

@rth
Copy link
Member

rth commented Oct 2, 2023

indexURL is expected to be a local folder

Though from a user perspective, it doesn't make sense not to be able to use remote indexURL in node. It sounds like a bug.

@tylfin
Copy link

tylfin commented Oct 2, 2023

Hmm, removing the option gives the same module error:

Uncaught (in promise) Error: Cannot find module 'http://localhost:8000/node_modules/pyodide/pyodide.asm.js'
    ./node_modules/pyodide lazy recursive/t/< lazy strict namespace object:5
    promise callback*t lazy strict namespace object:4

@esromerog
Copy link

I am having the same issue, downgraded to pyodide@0.23.4 and it works flawlessly now, but it does seem like the indexURL is broken in the current implementation. If using the latest version is strictly necessary, I think a possible solution is to add it to the project's public folder and link it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants