Fail: Microsoft.AspNetCore.SpaServices[0]
Solution 1
Find the answer by myself. It is still a bug of .NET-Core. Refreshing (F5) the page solved the problem and it works fine. (https://github.com/aspnet/JavaScriptServices/issues/1625)
Issues still exists, however just waiting it out and the angular builds, from my end the issue seems to be caused by the build order. What I mean is that the Server side code builds faster than the angular code, hence after waiting a second or two the error disappears.
Another way, if we run server first wait until webpack finish the compiling, then execute the command dotnet run
.
Solution 2
For ngcc lock file it is causing issue. Simply delete 'node_modules' folder in 'ClientApp' folder and re build the application.
Solution 3
To get detailed information regarding to the problem causing this error, run the app via:
npm start
instead of dotnet run
.
Then if the error message indicates something e.g. missing packages, you may need to install the missing package(s) and after the problem is fixed you can continue to use dotnet run
command as before.
Bigeyes
Updated on June 13, 2022Comments
-
Bigeyes almost 2 years
Asp.net core 2.1 +Angular 6 application. In my
Start.cs
file. we haveapp.UseSpa(spa => { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } });
In the morning, I run the asp.net core application from Visual Studio(click F5). I got webpack build stuck on build module. It build a scss file for a long time and hangs there. So the web page throws asp.net core middleware exception.
However in the afternoon, I got a different error. Which is
Fail: Microsoft.AspNetCore.SpaServices[0]
.However if I run
npm start
in command window, then rundotnet run
in Visual Studio code. It is fine.Tell me what to do?