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
+18 -15
+18 -15
View File
@@ -35,22 +35,25 @@ 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( 'npx tsx src/index.ts',
cmd, cwd=str(PROJECT_DIR),
cwd=str(PROJECT_DIR), stdout=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
stderr=subprocess.PIPE, env=env,
env=env, shell=True,
**extra, creationflags=0x08000000,
) )
else:
backend = subprocess.Popen(
['npx', 'tsx', 'src/index.ts'],
cwd=str(PROJECT_DIR),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
)
# Read stdout/stderr in background for log window # Read stdout/stderr in background for log window
def read_stream(stream, prefix=''): def read_stream(stream, prefix=''):