fix: use shell=True on Windows for npx.cmd

This commit is contained in:
zlm committed 2026-06-10 12:21:52 +08:00
1 parent c69358c317
commit 4656203e4d
1 file changed
+12 -9
+12 -9
View File
@@ -35,21 +35,24 @@ def start_backend():
env['PORT'] = '3000' env['PORT'] = '3000'
env['SKIP_PLC'] = '1' env['SKIP_PLC'] = '1'
# Use npx to run tsx, regardless of OS
cmd = ['npx', 'tsx', 'src/index.ts']
# Windows: hide console window
extra = {}
if sys.platform == 'win32': if sys.platform == 'win32':
extra['creationflags'] = 0x08000000 # CREATE_NO_WINDOW # Windows: npx.cmd needs shell=True; hide console
backend = subprocess.Popen( backend = subprocess.Popen(
cmd, 'npx tsx src/index.ts',
cwd=str(PROJECT_DIR),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
shell=True,
creationflags=0x08000000,
)
else:
backend = subprocess.Popen(
['npx', 'tsx', 'src/index.ts'],
cwd=str(PROJECT_DIR), cwd=str(PROJECT_DIR),
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
env=env, env=env,
**extra,
) )
# Read stdout/stderr in background for log window # Read stdout/stderr in background for log window