Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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.LTS };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://endoflife.date/nodejs

node 22's latest version updated to 22.22.0

removing version will install node 24 I believe, because that is the latest LTS.

replace 22.14.0 with 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")
Comment thread
HariniMalothu17 marked this conversation as resolved.
}

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