WebApi for Vue app errors, fails to call command line

23 Views Asked by At

I have a webApi that works with a vue app. I created it following a tutorial years ago.

I'm now getting an error, from the VueCliMiddleWare.(Exception at bottom), this error occurs in prod, but not in Dev. I can't reproduce it in dev.

I figured the issue out with this post, but I don't really understand what is going on.

The exception is long, but in essence a bad Path is getting passed into the VueCliMIddleWare in Startup.cs.

 app.UseSpa( spa =>
            {
                spa.Options.SourcePath = "ClientApp";// < --- Here

                spa.UseVueCli( npmScript: "serve" );

            } );

The clientapp folder doesn't exist, causing the exception below.

This is because, I'm not hosting a Vue app in this WebApi, it's just talking to one. So there is no Client app to deploy with the API, it's a separate application.

If I remove this code, the API can no longer communicate with the Vue app.

If I comment out the part that sets the ClientApp folder, the VueCliMiddleware throws an exception at startup.

My Question then is, what is that block of code actually doing for my WebApi?

From context it's handling the Vue Requests somehow, but that's about All I understand.

Is it safe to just change the path to "." so it runs in the same folder as the Exe? (If this reproduced in dev, I could answer this myself... but it does not, only in prod)

We recently converted from .netcore 2.2 to .net 6.0 (core?) so that may be why the error is now suddenly happening.

Update: I tried running it with: "ASPNETCORE_ENVIRONMENT": "Production"

but the error still does not reproduce for me. The error:

ex: System.AggregateException: One or more errors occurred. (One or more errors occurred. (Failed to start 'cmd'. To resolve this:.

1 Ensure that 'cmd' 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 (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0;C:\Program Files\dotnet; Make sure the executable is in one of those directories, or update your PATH.

[2] See the InnerException for further details of the cause.)) ---> System.AggregateException: One or more errors occurred. (Failed to start 'cmd'. To resolve this:.

1 Ensure that 'cmd' 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 (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0;C:\Program Files\dotnet; Make sure the executable is in one of those directories, or update your PATH.

[2] See the InnerException for further details of the cause.) ---> System.InvalidOperationException: Failed to start 'cmd'. To resolve this:.

1 Ensure that 'cmd' 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 (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0;C:\Program Files\dotnet; Make sure the executable is in one of those directories, or update your PATH.

[2] See the InnerException for further details of the cause. ---> System.ComponentModel.Win32Exception (267): An error occurred trying to start process 'cmd' with working directory 'ClientApp'. 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 VueCliMiddleware.ScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo) --- End of inner exception stack trace --- at VueCliMiddleware.ScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo) at VueCliMiddleware.ScriptRunner..ctor(String workingDirectory, String scriptName, String arguments, IDictionary2 envVars, ScriptRunnerType runner) at VueCliMiddleware.VueCliMiddleware.StartVueCliServerAsync(String sourcePath, String npmScriptName, ILogger logger, Int32 portNumber, ScriptRunnerType runner, String regex) --- End of inner exception stack trace --- at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at VueCliMiddleware.VueCliMiddleware.<>c.<Attach>b__3_0(Task1 task) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at VueCliMiddleware.TaskTimeoutExtensions.WithTimeout[T](Task1 task, TimeSpan timeoutDelay, String message) at Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task`1 baseUriTask, CancellationToken applicationStoppingToken, Boolean proxy404s) at Microsoft.AspNetCore.Builder.SpaProxyingExtensions.<>c__DisplayClass2_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

0

There are 0 best solutions below

Related Questions in VUECLIMIDDLEWARE