Asp.net core 2.1 +Angular 6 application. In my Start.cs
file. we have
app.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 run dotnet run
in Visual Studio code. It is fine.
Tell me what to do?
For ngcc lock file it is causing issue. Simply delete 'node_modules' folder in 'ClientApp' folder and re build the application.
I had a similar error as above (Fail: Microsoft.AspNetCore.SpaServices[0]) but for dotnet CLI (version 3.0.100, Angular 8.0). I simply created an Angular project - no error generated during build but when I ran it got the above error. After 10 minutes of investigation found the following issue during running angular server on it own:
This is because the path for the module HomeComponent was blank:
This code was autogenerated by dotnet tool so I am not sure why this was left out. The HomeComponent module is in Home folder. So adding the path solved the problem.
This may be useful for other newbies out there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With