From 4abd26159120bd994c465145d0eb868b709ef382 Mon Sep 17 00:00:00 2001 From: Harini Malothu Date: Thu, 15 Jan 2026 15:45:17 +0530 Subject: [PATCH 1/3] Fix rnw-dependencies.ps1 Node.js installation failures --- vnext/Scripts/rnw-dependencies.ps1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/vnext/Scripts/rnw-dependencies.ps1 b/vnext/Scripts/rnw-dependencies.ps1 index 7d401ba3b67..147527b9376 100644 --- a/vnext/Scripts/rnw-dependencies.ps1 +++ b/vnext/Scripts/rnw-dependencies.ps1 @@ -469,7 +469,7 @@ $requirements = @( Name = 'Node.js (LTS, >= 22.0)'; Tags = @('appDev'); Valid = { CheckNode; } - Install = { WinGetInstall OpenJS.NodeJS.LTS "22.14.0" }; + Install = { WinGetInstall OpenJS.NodeJS.LTS }; HasVerboseOutput = $true; }, @{ @@ -600,6 +600,9 @@ function WinGetInstall { Write-Verbose "Executing `winget install `"$wingetPackage`""; & winget install "$wingetPackage" --accept-source-agreements --accept-package-agreements } + + # Refresh PATH environment variable to pick up newly installed tools + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") } function IsElevated { @@ -685,6 +688,17 @@ foreach ($req in $filteredRequirements) $LASTEXITCODE = 0; $outputFromInstall = Invoke-Command $req.Install -ErrorAction Stop; + # Re-validate after install attempt - winget may return non-zero for "already installed" + $validAfterInstall = $false; + try { + $validAfterInstall = Invoke-Command $req.Valid; + } catch { } + + if ($validAfterInstall) { + $Installed++; + continue; # go to the next item + } + if ($LASTEXITCODE -ne 0) { throw "Last exit code was non-zero: $LASTEXITCODE - $outputFromInstall"; } From fd95a2f8f6ebf3a390b10b484c591239e05ccbb3 Mon Sep 17 00:00:00 2001 From: Harini Malothu Date: Thu, 15 Jan 2026 15:54:42 +0530 Subject: [PATCH 2/3] Change files --- ...ative-windows-3211d67c-3146-40b2-8d6b-5c2ef4008bd7.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-3211d67c-3146-40b2-8d6b-5c2ef4008bd7.json diff --git a/change/react-native-windows-3211d67c-3146-40b2-8d6b-5c2ef4008bd7.json b/change/react-native-windows-3211d67c-3146-40b2-8d6b-5c2ef4008bd7.json new file mode 100644 index 00000000000..20e8bcf603f --- /dev/null +++ b/change/react-native-windows-3211d67c-3146-40b2-8d6b-5c2ef4008bd7.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Fix rnw-dependencies.ps1 Node.js installation failures", + "packageName": "react-native-windows", + "email": "hmalothu@microsoft.com", + "dependentChangeType": "none" +} From 64424d72413a488157cc5acdf670375f780dcfec Mon Sep 17 00:00:00 2001 From: Harini Malothu Date: Mon, 19 Jan 2026 13:59:18 +0530 Subject: [PATCH 3/3] Fix node.js version --- vnext/Scripts/rnw-dependencies.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vnext/Scripts/rnw-dependencies.ps1 b/vnext/Scripts/rnw-dependencies.ps1 index 147527b9376..1adefd0123e 100644 --- a/vnext/Scripts/rnw-dependencies.ps1 +++ b/vnext/Scripts/rnw-dependencies.ps1 @@ -469,7 +469,7 @@ $requirements = @( Name = 'Node.js (LTS, >= 22.0)'; Tags = @('appDev'); Valid = { CheckNode; } - Install = { WinGetInstall OpenJS.NodeJS.LTS }; + Install = { WinGetInstall OpenJS.NodeJS.LTS "22.22.0"}; HasVerboseOutput = $true; }, @{