You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a working on a simple Node.js express app, which can call the gradio client to play with space apis.
I encountered several errors about "EventSource" not defined, and "window" not defined, errors i have been able to solve :)
Here's the workaround for @gradio/client 0.10.1 and Node.js v18.16.0
Note that we are workin with ES6 Syntax.
#1 First make sure in your package.json file you add
@fffiloni Is there any solution to get it running with private spaces. Instead of Node.js , i tried with https://deno.land/ ,but i get different errors
I'll keep this open for points 1 and 2 and will change the title.
pngwn
changed the title
@Gradio/client 0.10.1 Multiple changes to avoid errors in Node.js apps
window not defined + document "type": "module" requirement.
Apr 11, 2024
Describe the bug
Hello !
I'm a working on a simple Node.js express app, which can call the gradio client to play with space apis.
I encountered several errors about "EventSource" not defined, and "window" not defined, errors i have been able to solve :)
Here's the workaround for @gradio/client 0.10.1 and Node.js v18.16.0
Note that we are workin with ES6 Syntax.
#1 First make sure in your package.json file you add
#2 About EventSource
npm install eventsource
then in your server.js add
then in file
/node_modules/@gradio/client/dist/index.js
line 744 replace:
replace:
by adding .toString() to url arg:
—
same operation to line 1060
by adding .toString() to url arg:
—
#3 About window not defined
It's not finished, now you will get window not defined event, so in file
/node_modules/@gradio/client/dist/index.js:1078
line 1078
replace:
by :
—
So now in your main server.js, your code should be like this:
It should now work, as it works on my hand, console should log:
[ 'Hello John!' ]
Have you searched existing issues? 🔎
Reproduction
Screenshot
No response
Logs
/node_modules/@gradio/client/dist/index.js:1209 (...args) => new EventSource(...args) ^ ReferenceError: EventSource is not defined
System Info
@gradio/client 0.10.1
Node.js v18.16.0
Severity
I can work around it
The text was updated successfully, but these errors were encountered: