Skip to content

Commit ffb37fb

Browse files
JohnMcLearclaude
andcommitted
fix(installer): parse node --version in PowerShell (Windows PowerShell 5.1)
Windows PowerShell 5.1 strips embedded double quotes from native-command arguments, so `node -p 'process.versions.node.split(".")[0]'` reached node as split(.)[0], threw a SyntaxError, cast to 0, and aborted with 'Node.js >= 24 required' for any Node version. Fixes #8214 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139nGyeFNACmifj6pRLSVRs
1 parent 9f5bf67 commit ffb37fb

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

bin/installer.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ if (-not (Test-Cmd node)) {
5050
Write-Fatal "Node.js is required (>= $RequiredNodeMajor). Install it from https://nodejs.org"
5151
}
5252

53-
$nodeMajor = [int](node -p 'process.versions.node.split(".")[0]')
53+
# Parse `node --version` (e.g. "v24.15.0") in PowerShell rather than passing a
54+
# JS snippet to `node -p`: Windows PowerShell 5.1 strips embedded double quotes
55+
# from native-command arguments, which mangled the snippet into a SyntaxError
56+
# and made every Node version look too old (#8214).
57+
$nodeVer = "$(node --version)".Trim()
58+
if (-not ($nodeVer -match '^v(\d+)\.')) {
59+
Write-Fatal "Could not determine the Node.js version (got '$nodeVer'). Node.js >= $RequiredNodeMajor is required."
60+
}
61+
$nodeMajor = [int]$Matches[1]
5462
if ($nodeMajor -lt $RequiredNodeMajor) {
55-
$nodeVer = (node --version)
5663
Write-Fatal "Node.js >= $RequiredNodeMajor required. You have $nodeVer."
5764
}
5865

0 commit comments

Comments
 (0)