@@ -34,7 +34,7 @@ IPyInstallationManager pyInstallationManager
3434 private const string TkinterDownloadUrl =
3535 "https://cdn.lykos.ai/tkinter-cpython-embedded-3.10.11-win-x64.zip" ;
3636
37- private const string NodeDownloadUrl = "https://nodejs.org/dist/v20.11.0 /node-v20.11.0 -win-x64.zip" ;
37+ private const string NodeDownloadUrl = "https://nodejs.org/dist/v20.19.3 /node-v20.19.3 -win-x64.zip" ;
3838
3939 private const string Dotnet7DownloadUrl =
4040 "https://download.visualstudio.microsoft.com/download/pr/2133b143-9c4f-4daa-99b0-34fa6035d67b/193ede446d922eb833f1bfe0239be3fc/dotnet-sdk-7.0.405-win-x64.zip" ;
@@ -89,6 +89,7 @@ private string GetPythonLibraryZipPath(PyVersion version) =>
8989 private string TkinterExtractPath => Path . Combine ( AssetsDir , "Python310" ) ;
9090 private string TkinterExistsPath => Path . Combine ( TkinterExtractPath , "tkinter" ) ;
9191 private string NodeExistsPath => Path . Combine ( AssetsDir , "nodejs" , "npm.cmd" ) ;
92+ private string NodeExePath => Path . Combine ( AssetsDir , "nodejs" , "node.exe" ) ;
9293 private string NodeDownloadPath => Path . Combine ( AssetsDir , "nodejs.zip" ) ;
9394 private string Dotnet7DownloadPath => Path . Combine ( AssetsDir , "dotnet-sdk-7.0.405-win-x64.zip" ) ;
9495 private string Dotnet8DownloadPath => Path . Combine ( AssetsDir , "dotnet-sdk-8.0.101-win-x64.zip" ) ;
@@ -176,6 +177,20 @@ public Task<ProcessResult> GetGitOutput(ProcessArgs args, string? workingDirecto
176177 ) ;
177178 }
178179
180+ private async Task < string > RunNode (
181+ ProcessArgs args ,
182+ string ? workingDirectory = null ,
183+ IReadOnlyDictionary < string , string > ? envVars = null
184+ )
185+ {
186+ var result = await ProcessRunner
187+ . GetProcessResultAsync ( NodeExePath , args , workingDirectory , envVars )
188+ . ConfigureAwait ( false ) ;
189+
190+ result . EnsureSuccessExitCode ( ) ;
191+ return result . StandardOutput ?? result . StandardError ?? string . Empty ;
192+ }
193+
179194 public async Task RunNpm (
180195 ProcessArgs args ,
181196 string ? workingDirectory = null ,
@@ -685,12 +700,31 @@ await downloadService.DownloadToFileAsync(
685700 [ SupportedOSPlatform ( "windows" ) ]
686701 public async Task InstallNodeIfNecessary ( IProgress < ProgressReport > ? progress = null )
687702 {
688- if ( File . Exists ( NodeExistsPath ) )
689- return ;
703+ // NOTE TO FUTURE DEVS: if this is causing merge conflicts with dev, just nuke it we don't need anymore
704+ var nodeFolder = new DirectoryPath ( AssetsDir , "nodejs" ) ;
705+ if ( nodeFolder . Exists )
706+ {
707+ try
708+ {
709+ var result = await RunNode ( "-v" ) ;
710+ if ( result . Contains ( "20.19.3" ) )
711+ {
712+ Logger . Debug ( "Node.js already installed at {NodeExistsPath}" , NodeExistsPath ) ;
713+ return ;
714+ }
715+ }
716+ catch ( Exception )
717+ {
718+ // ignored
719+ }
720+
721+ Logger . Warn ( "Node.js version mismatch, reinstalling..." ) ;
722+ await nodeFolder . DeleteAsync ( true ) ;
723+ }
690724
691725 await DownloadAndExtractPrerequisite ( progress , NodeDownloadUrl , NodeDownloadPath , AssetsDir ) ;
692726
693- var extractedNodeDir = Path . Combine ( AssetsDir , "node-v20.11.0 -win-x64" ) ;
727+ var extractedNodeDir = Path . Combine ( AssetsDir , "node-v20.19.3 -win-x64" ) ;
694728 if ( Directory . Exists ( extractedNodeDir ) )
695729 {
696730 Directory . Move ( extractedNodeDir , Path . Combine ( AssetsDir , "nodejs" ) ) ;
0 commit comments