Skip to content

Commit fbb8054

Browse files
Make error message clearer if Node isn't installed (or not found on PATH). Fixesaspnet#527
1 parent 70f59fc commit fbb8054

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

‎src/Microsoft.AspNetCore.NodeServices/HostingModels/OutOfProcessNodeInstance.cs‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ protected virtual ProcessStartInfo PrepareNodeProcessStartInfo(
222222
}
223223
else
224224
{
225-
debuggingArgs=string.Empty;
225+
debuggingArgs=string.Empty;
226226
}
227227

228228
varthisProcessPid=Process.GetCurrentProcess().Id;
@@ -325,17 +325,26 @@ private static void SetEnvironmentVariable(ProcessStartInfo startInfo, string na
325325

326326
privatestaticProcessLaunchNodeProcess(ProcessStartInfostartInfo)
327327
{
328-
varprocess=Process.Start(startInfo);
329-
330-
// On Mac at least, a killed child process is left open as a zombie until the parent
331-
// captures its exit code. We don't need the exit code for this process, and don't want
332-
// to use process.WaitForExit() explicitly (we'd have to block the thread until it really
333-
// has exited), but we don't want to leave zombies lying around either. It's sufficient
334-
// to use process.EnableRaisingEvents so that .NET will grab the exit code and let the
335-
// zombie be cleaned away without having to block our thread.
336-
process.EnableRaisingEvents=true;
337-
338-
returnprocess;
328+
try{
329+
varprocess=Process.Start(startInfo);
330+
331+
// On Mac at least, a killed child process is left open as a zombie until the parent
332+
// captures its exit code. We don't need the exit code for this process, and don't want
333+
// to use process.WaitForExit() explicitly (we'd have to block the thread until it really
334+
// has exited), but we don't want to leave zombies lying around either. It's sufficient
335+
// to use process.EnableRaisingEvents so that .NET will grab the exit code and let the
336+
// zombie be cleaned away without having to block our thread.
337+
process.EnableRaisingEvents=true;
338+
339+
returnprocess;
340+
}catch(Exceptionex){
341+
varmessage="Failed to start Node process. To resolve this:.\n\n"
342+
+"[1] Ensure that Node.js is installed and can be found in one of the PATH directories.\n"
343+
+$" Current PATH enviroment variable is: {Environment.GetEnvironmentVariable("PATH") }\n"
344+
+" Make sure the Node executable is in one of those directories, or update your PATH.\n\n"
345+
+"[2] See the InnerException for further details of the cause.";
346+
thrownewInvalidOperationException(message,ex);
347+
}
339348
}
340349

341350
privatestaticstringUnencodeNewlines(stringstr)

0 commit comments

Comments
(0)