⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"
}
16 changes: 15 additions & 1 deletion vnext/Scripts/rnw-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.22 "22.22.0"};
HasVerboseOutput = $true;
},
@{
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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";
}
Expand Down
Loading