2
votes

enter image description hereI create a new Web Project .Net Core with Angular template in Visual Studio 2019. When I try to build solution I have a error: An unhandled exception occurred while processing the request. AggregateException: One or more errors occurred. (One or more errors occurred. (The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: )) System.Threading.Tasks.Task.ThrowIfExceptional(bool includeTaskCanceledExceptions)

InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(string sourcePath, string npmScriptName, ILogger logger).

1
Something failed when trying to start the angular part of your app. I'd try to start the angular app outside of visual studio (command line) hoping to get more error details there. See docs.microsoft.com/en-us/aspnet/core/client-side/spa/…Christoph Lütjen
Maybe the npm install failed and not all the needed thirdparties are downloaded properly. Could you please navigate in console into the ClientApp folder and call npm install? What is the output of the install? Is there any error while installation?Milan Tenk
I try npm install and also I run the app from console line, but still give me the same errorGjurgica
If you try to run only the Angular app from command line, do you get any errors? To start only the Angular app from command line navigate into the ClientApp folder and run npm run start.Milan Tenk
Could you please try to replace in the Startup.cs file the spa.UseAngularCliServer(..) invocation to spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");. After this try npm run start command line command from the ClientApp folder and after that start the .NET Core application from Visual Studio or from the command line using dotnet run.Milan Tenk

1 Answers

5
votes

As in the comments of the question turned out the default configuration in the request-response pipeline (in the Startup.cs) with spa.UseAngularCliServer(..) invocation did not work.

Changing the spa.UseAngularCliServer(..) invocation to spa.UseProxyToSpaDevelopmentServer("http://localhost:4200"); solved the issue. This way the Angular application has to be started separately from the root of the ClientApp folder using npm run start command-line command.

Further details about using UseProxyToSpaDevelopmentServer can be found here.