From f2fa27058ad9170f67bb6a1e1960bfb6ed2a2a76 Mon Sep 17 00:00:00 2001 From: Rodrigo Ribeiro Gomes Date: Thu, 21 Nov 2024 12:27:19 -0300 Subject: [PATCH] Fix Node.js start in Windows (#10001) * Update node_server.py Fix node start error in Windows systems, due to file nomenclature. Fix #9903 * add changeset * format --------- Co-authored-by: Abubakar Abid Co-authored-by: gradio-pr-bot --- .changeset/six-apes-greet.md | 5 +++++ gradio/node_server.py | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .changeset/six-apes-greet.md diff --git a/.changeset/six-apes-greet.md b/.changeset/six-apes-greet.md new file mode 100644 index 0000000000000..578fbdd08eb58 --- /dev/null +++ b/.changeset/six-apes-greet.md @@ -0,0 +1,5 @@ +--- +"gradio": patch +--- + +fix:Fix Node.js start in Windows diff --git a/gradio/node_server.py b/gradio/node_server.py index 7903ecd32a6cb..22f9f28e91655 100644 --- a/gradio/node_server.py +++ b/gradio/node_server.py @@ -102,10 +102,15 @@ def start_node_process( if GRADIO_LOCAL_DEV_MODE: env["GRADIO_LOCAL_DEV_MODE"] = "1" - register_file = Path(__file__).parent.joinpath("templates", "register.mjs") + register_file = str( + Path(__file__).parent.joinpath("templates", "register.mjs") + ) + + if sys.platform == "win32": + register_file = "file://" + register_file node_process = subprocess.Popen( - [node_path, "--import", str(register_file), SSR_APP_PATH], + [node_path, "--import", register_file, SSR_APP_PATH], stdout=subprocess.DEVNULL, env=env, )