How to use pyodide with next js?
Unanswered
XotEmBotZ posted this in #help-forum
I am trying to import pyodide but getting this error
The file
Module build failed: UnhandledSchemeError: Reading from "node:child_process" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:child_process
./node_modules/pyodide/pyodide.mjs
./src/components/Python.jsThe file
'use client'
import { } from "pyodide"
import { useEffect, useRef } from "react"
const Python = () => {
const pyodide = useRef(null)
useEffect(() => {
pyodide.current=1
}, [])
return (
<section>
<script src="https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js"></script>
{
async function main(){
let pyodide = await loadPyodide();
console.log(pyodide.runPython("1 + 2"));
}
}
</section>
)
}
export default Python