diff --git a/src/cli/run-main.ts b/src/cli/run-main.ts index 6d485130a..d9faa981f 100644 --- a/src/cli/run-main.ts +++ b/src/cli/run-main.ts @@ -1,3 +1,4 @@ +import fs from "node:fs"; import path from "node:path"; import process from "node:process"; import { fileURLToPath } from "node:url"; @@ -82,13 +83,16 @@ function stripWindowsNodeExec(argv: string[]): string[] { const execBase = path.basename(execPath).toLowerCase(); const isExecPath = (value: string | undefined): boolean => { if (!value) return false; - const lower = normalizeCandidate(value).toLowerCase(); + const normalized = normalizeCandidate(value); + if (!normalized) return false; + const lower = normalized.toLowerCase(); return ( lower === execPathLower || path.basename(lower) === execBase || lower.endsWith("\\node.exe") || lower.endsWith("/node.exe") || - lower.includes("node.exe") + lower.includes("node.exe") || + (path.basename(lower) === "node.exe" && fs.existsSync(normalized)) ); }; const filtered = argv.filter((arg, index) => index === 0 || !isExecPath(arg));