TimeoutException: The Angular CLI process did not start listening for requests within the timeout period of 0 seconds

前端 未结 11 1936
天命终不由人
天命终不由人 2020-12-09 15:25

I\'m getting this error after upgrading to angular 9. I\'m using visual studio 2019, ASP .NET core with angular. Even if I create new project and update angular to 9 version

相关标签:
11条回答
  • 2020-12-09 16:05

    None of the solutions here worked for me. The problem began after I upgrade components of my solution to their last versions. The only thing that works for me is to upgrade my global angular cli to have same version as my local one :

    npm uninstall -g angular-cli
    npm cache clean
    npm cache verify
    npm install -g @angular/cli@latest
    
    0 讨论(0)
  • 2020-12-09 16:06

    I added verbosity to the serving process in the file package.json like this.

    "scripts": {
      "ng": "ng",
      "start": "ng serve --verbose",
      "build": "ng build", ...
    }, ...
    

    No idea why it worked but I sense it somehow relates to causing the same slowdown as echo does.

    0 讨论(0)
  • 2020-12-09 16:08

    If you are doing backend work only, in your startup.cs comment out

    spa.UseAngularCliServer(npmScript: "start");
    

    and add

    spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
    

    Like so...

    //spa.UseAngularCliServer(npmScript: "start");
    spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");//Todo Switch back for SPA Dev
    

    Run the SPA from cmd (in ClientApp Directory) via npm start.

    Then when your run or debug your full app from Visual Studio, it will spin up so much faster.

    0 讨论(0)
  • 2020-12-09 16:09

    As suggested in https://developercommunity.visualstudio.com/solutions/446713/view.html, you should setup the StartupTimeout configuration setting.

    Basically in Startup.cs:

     app.UseSpa(spa =>
        {
          spa.Options.SourcePath = "./";
          //Configure the timeout to 5 minutes to avoid "The Angular CLI process did not start listening for requests within the timeout period of 50 seconds." issue
          spa.Options.StartupTimeout = new TimeSpan(0, 5, 0);
          if (env.IsDevelopment())
          {
            spa.UseAngularCliServer(npmScript: "start");
          }
        });
    
    0 讨论(0)
  • 2020-12-09 16:13

    to resolve the strict mode error remove this line from main.ts

    export { renderModule, renderModuleFactory } from '@angular/platform-server';
    

    This doesn't resolve the timeout issue however. I am also getting this error after upgrading to Angular 9 and using .NET core.

    Running the angular app using "ng serve" and then changing your startup spa script to use UseProxyToSpaDevelopmentServer works as a work-around

    0 讨论(0)
  • 2020-12-09 16:13

    In my case there were TypeScript compile errors that were not caught by SpaServices or ts-node. There were references using the same file name with different namespaces that confused the runtime compiler. Execute ng build in the ClientApp folder and make sure there are no errors.

    0 讨论(0)
提交回复
热议问题