fix(ssh): probe npm via prepended PATH, not colocated with node (#9165) (#9255)

* fix(ssh): probe npm via prepended PATH, not colocated with node (#9165)

The remote Node/npm toolchain gate invoked npm by its absolute path
<nodeBinDir>/npm (POSIX) / npm.cmd (Windows, behind a Test-Path
colocation check). But deploy (commandWithNodePath) runs bare `npm`
with nodeBinDir merely prepended to PATH, so npm can resolve from
anywhere on PATH.

A host whose only resolvable node has npm elsewhere on PATH (e.g. node
symlinked into a dir without npm) deployed fine on v1.4.144, but after
upgrade the candidate is rejected with no fallback → SSH/relay
connection fails to establish.

Make the probe resolve npm exactly the way deploy does — bare
`npm --version` under the same prepended PATH — so it still confirms npm
is runnable (the #8450 concern) without requiring colocation. Windows
now prepends the backslash-form dir (matching deploy) so bare-command
PATH lookup resolves reliably.

* test(ssh): cover split Node npm PATH resolution
This commit is contained in:
Brennan Benson
2026-07-17 19:29:43 -07:00
parent 212b79a03a
commit 5346efcb7f
4 changed files with 55 additions and 18 deletions
+2 -3
View File
@@ -174,9 +174,8 @@ async function tryResolveViaLoginShell(
return null
}
// Returns true if `nodePath` runs, reports Node >= 18, and has a runnable npm
// beside it. Deployment prepends this same directory before invoking npm, so
// accepting a looser pairing would recreate #8450.
// Validates the same PATH-prepend + bare npm contract used during deployment.
// This rejects missing npm (#8450) without requiring colocation (#9165).
// Caches nothing — this runs at most a few times per resolution (one per
// candidate), and the exec round-trip dominates.
async function nodeToolchainMeetsRequirements(