NodeServices 2.1.0-rc1-final can't find path to nodejs #64

Closed
opened 2025-08-09 17:14:52 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @jsfeldman on 5/16/2018

After upgrading NodeServices to the 2.1.0-rc1-final on my test application I noticed that calls to NodeServices were no longer successful. I was receiving this error message:

Connection id "0HLDR6OS0IAFB", Request id "0HLDR6OS0IAFB:00000001": An unhandled exception was thrown by the application.
System.InvalidOperationException: Failed to start Node process. To resolve this:.

[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
    Current PATH enviroment variable is: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Program Files (x86)\dotnet\;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps
    Make sure the Node executable is in one of those directories, or update your PATH.

[2] See the InnerException for further details of the cause. ---> System.ComponentModel.Win32Exception: The directory name is invalid

C:\Program Files\nodejs contains the node executable and I was able to run an application with an old version of NodeServices without any issues.
I looked into it a little more and noticed that C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps in not a valid directory. I believe the latest version of NodeServices fails when it encounters an invalid path whereas older versions might have handled the exception.

Unfortunately, even after removing the invalid path from PATH, the error message still contains the invalid path so I think it must be cached somewhere and I can't restart the server at this time. I'll update this post once I'm able to test it.

Here is the full stack trace in case it is useful:

System.InvalidOperationException: Failed to start Node process. To resolve this:.

[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
    Current PATH enviroment variable is: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Program Files (x86)\dotnet\;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps
    Make sure the Node executable is in one of those directories, or update your PATH.

[2] See the InnerException for further details of the cause. ---> System.ComponentModel.Win32Exception: The directory name is invalid
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo)
   at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance..ctor(String entryPointScript, String projectPath, String[] watchFileExtensions, String commandLineArguments, CancellationToken applicationStoppingToken, ILogger nodeOutputLogger, IDictionary`2 environmentVars, Int32 invocationTimeoutMilliseconds, Boolean launchWithDebugging, Int32 debuggingPort)
   at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance..ctor(NodeServicesOptions options, Int32 port)
   at Microsoft.AspNetCore.NodeServices.HostingModels.NodeServicesOptionsExtensions.<>c__DisplayClass0_0.<UseHttpHosting>b__0()
   at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.CreateNewNodeInstance()
   at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.GetOrCreateCurrentNodeInstance()
   at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.InvokeExportWithPossibleRetryAsync[T](String moduleName, String exportedFunctionName, Object[] args, Boolean allowRetry, CancellationToken cancellationToken)
   at MobileFormsBackend.Controllers.PatientController.SubmitProfile(Profile profile) in C:\Users\jfeldman\Source\Repos\eForms\Controllers\PatientController.cs:line 503
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
*Originally created by @jsfeldman on 5/16/2018* After upgrading NodeServices to the 2.1.0-rc1-final on my test application I noticed that calls to NodeServices were no longer successful. I was receiving this error message: ``` Connection id "0HLDR6OS0IAFB", Request id "0HLDR6OS0IAFB:00000001": An unhandled exception was thrown by the application. System.InvalidOperationException: Failed to start Node process. To resolve this:. [1] Ensure that Node.js is installed and can be found in one of the PATH directories. Current PATH enviroment variable is: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Program Files (x86)\dotnet\;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps Make sure the Node executable is in one of those directories, or update your PATH. [2] See the InnerException for further details of the cause. ---> System.ComponentModel.Win32Exception: The directory name is invalid ``` `C:\Program Files\nodejs` contains the node executable and I was able to run an application with an old version of NodeServices without any issues. I looked into it a little more and noticed that `C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps` in not a valid directory. I believe the latest version of NodeServices fails when it encounters an invalid path whereas older versions might have handled the exception. Unfortunately, even after removing the invalid path from PATH, the error message still contains the invalid path so I think it must be cached somewhere and I can't restart the server at this time. I'll update this post once I'm able to test it. Here is the full stack trace in case it is useful: ``` System.InvalidOperationException: Failed to start Node process. To resolve this:. [1] Ensure that Node.js is installed and can be found in one of the PATH directories. Current PATH enviroment variable is: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Program Files (x86)\dotnet\;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps Make sure the Node executable is in one of those directories, or update your PATH. [2] See the InnerException for further details of the cause. ---> System.ComponentModel.Win32Exception: The directory name is invalid at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo) --- End of inner exception stack trace --- at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo) at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance..ctor(String entryPointScript, String projectPath, String[] watchFileExtensions, String commandLineArguments, CancellationToken applicationStoppingToken, ILogger nodeOutputLogger, IDictionary`2 environmentVars, Int32 invocationTimeoutMilliseconds, Boolean launchWithDebugging, Int32 debuggingPort) at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance..ctor(NodeServicesOptions options, Int32 port) at Microsoft.AspNetCore.NodeServices.HostingModels.NodeServicesOptionsExtensions.<>c__DisplayClass0_0.<UseHttpHosting>b__0() at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.CreateNewNodeInstance() at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.GetOrCreateCurrentNodeInstance() at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.InvokeExportWithPossibleRetryAsync[T](String moduleName, String exportedFunctionName, Object[] args, Boolean allowRetry, CancellationToken cancellationToken) at MobileFormsBackend.Controllers.PatientController.SubmitProfile(Profile profile) in C:\Users\jfeldman\Source\Repos\eForms\Controllers\PatientController.cs:line 503 at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at System.Threading.Tasks.ValueTask`1.get_Result() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#64
No description provided.