title: Failed to start NPM when published to IIS
body: <p>I'm publishing my asp.net core 2.2 Angular 7 web application to IIS and I get below errors:</p>
  
  <ol>
  <li>Ensure that 'npm' is installed and can be found in one of the PATH directories.</li>
  <li>InvalidOperationException: Failed to start 'npm'.</li>
  <li>AggregateException: One or more errors occurred. (One or more errors occurred. (Failed to start 'npm'. To resolve this:. [1] Ensure that 'npm' is installed and can be found in one of the PATH directories).</li>
  </ol>
  
  <p>This is for a Asp.Net core web application on Windows 2012 R2 server running IIS 8.
  My local machine with IIS 8 has same errors.</p>
  
  <hr>
  
  <p>My launchsettings.json profile:</p>
  
  <pre><code>   "Test.IIS": {
          "commandName": "IIS",
          "launchBrowser": true,
          "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
     },
     "ancmHostingModel": "InProcess",
     "applicationUrl": "ttps://localhost:5002"
     }
  </code></pre>
  
  <hr>
  
  <p>Below is my startup.cs file:</p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
  
          // In production, the Angular files will be served from this directory
          services.AddSpaStaticFiles(configuration =&gt;
          {
              configuration.RootPath = "ClientApp/dist";
          });
      }
  
  
      public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          else
          {
              app.UseExceptionHandler("/Error");
              // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
              app.UseHsts();
          }
  
          //To check which process is runing the application
          //app.Run(async (contenxt) =&gt; {
          //    await contenxt.Response.WriteAsync(System.Diagnostics.Process.GetCurrentProcess().ProcessName);
          //});
  
          app.UseHttpsRedirection();
          app.UseStaticFiles();
          app.UseSpaStaticFiles();
  
          app.UseMvc(routes =&gt;
          {
              routes.MapRoute(
                  name: "default",
                  template: "{controller}/{action=Index}/{id?}");
          });
  
          app.UseSpa(spa =&gt;
          {
              // 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");
              }
          });
      }
  </code></pre>
  
  <p>The code compiles successfully but throws the errors in run time.</p>