title: Failed to start 'npm': Ensure that 'npm' is installed and can be found
body: <p>In Visual Studio 2019 v16.4.1 when attempting to run a ASP.NET Core Web Application with React installed I get an error in the loading webpage:</p>
  
  <pre><code>Failed to start 'npm': Ensure that 'npm' is installed and can be found in one of the PATH directories.
  </code></pre>
  
  <p>In the System Environment Variables, Path includes C:\Program Files\nodejs and C:\Users\me\AppData\Roaming\npm amongst others.  </p>
  
  <p>Entering 'npm' in the VS 2019 Package Manager Console produces no errors and finishes with  <code>npm@6.12.1 C:\Program Files\nodejs\node_modules\npm</code>. So that appears OK.</p>
  
  <p>The InnerException on the page includes:</p>
  
  <pre><code>System.ComponentModel.Win32Exception (267): The directory name is invalid.
  </code></pre>
  
  <p>This error has been documented and marked as resolved at:</p>
  
  <p><a href="https://github.com/aspnet/AspNetCore/issues/6342" rel="noreferrer">https://github.com/aspnet/AspNetCore/issues/6342</a></p>
  
  <pre><code>"but the real rub is hidden in the InnerException:
  
  System.ComponentModel.Win32Exception: The directory name is invalid.
  "
  </code></pre>
  
  <p>But I'm still having the problem with VS 2019...</p>
  
  <p>Any ideas how to resolve this?</p>
  
  <pre><code>System.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.
      Current PATH enviroment variable is: C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\PuTTY\;C:\Program Files (x86)\Bitvise SSH Client;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\nodejs\;C:\Users\00082563\AppData\Local\Microsoft\WindowsApps;C:\Users\00082563\.dotnet\tools;C:\Users\00082563\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\00082563\AppData\Roaming\npm;C:\Users\00082563\.nuget\packages\node.js\5.3.0\tools
      Make sure the executable is in one of those directories, or update your PATH.
  
  [2] See the InnerException for further details of the cause.))
  
   ---&gt; System.AggregateException: 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.
      Current PATH enviroment variable is: C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\PuTTY\;C:\Program Files (x86)\Bitvise SSH Client;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\nodejs\;C:\Users\00082563\AppData\Local\Microsoft\WindowsApps;C:\Users\00082563\.dotnet\tools;C:\Users\00082563\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\00082563\AppData\Roaming\npm;C:\Users\00082563\.nuget\packages\node.js\5.3.0\tools
      Make sure the executable is in one of those directories, or update your PATH.
  
  [2] See the InnerException for further details of the cause.)
  
   ---&gt; System.InvalidOperationException: Failed to start 'npm'. To resolve this:.
  
  [1] Ensure that 'npm' is installed and can be found in one of the PATH directories.
      Current PATH enviroment variable is: C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\PuTTY\;C:\Program Files (x86)\Bitvise SSH Client;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\nodejs\;C:\Users\00082563\AppData\Local\Microsoft\WindowsApps;C:\Users\00082563\.dotnet\tools;C:\Users\00082563\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\00082563\AppData\Roaming\npm;C:\Users\00082563\.nuget\packages\node.js\5.3.0\tools
      Make sure the executable is in one of those directories, or update your PATH.
  
  [2] See the InnerException for further details of the cause.
  
   ---&gt; System.ComponentModel.Win32Exception (267): The directory name is invalid.
  
     at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
  
     at System.Diagnostics.Process.Start()
  
     at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
  
     at Microsoft.AspNetCore.NodeServices.Npm.NpmScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo)
  
     --- End of inner exception stack trace ---
  
     at Microsoft.AspNetCore.NodeServices.Npm.NpmScriptRunner.LaunchNodeProcess(ProcessStartInfo startInfo)
  
     at Microsoft.AspNetCore.NodeServices.Npm.NpmScriptRunner..ctor(String workingDirectory, String scriptName, String arguments, IDictionary`2 envVars)
  
     at Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer.ReactDevelopmentServerMiddleware.StartCreateReactAppServerAsync(String sourcePath, String npmScriptName, ILogger logger)
  
     --- End of inner exception stack trace ---
  
     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
  
     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
  
     at System.Threading.Tasks.Task`1.get_Result()
  
     at Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer.ReactDevelopmentServerMiddleware.&lt;&gt;c.&lt;Attach&gt;b__2_0(Task`1 task)
  
     at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
  
     at System.Threading.Tasks.Task.&lt;&gt;c.&lt;.cctor&gt;b__274_0(Object obj)
  
     at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
  
  --- End of stack trace from previous location where exception was thrown ---
  
     at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
  
     at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task&amp; currentTaskSlot, Thread threadPoolThread)
  
     --- End of inner exception stack trace ---
  
     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
  
     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
  
     at System.Threading.Tasks.Task`1.get_Result()
  
     at Microsoft.AspNetCore.SpaServices.Extensions.Util.TaskTimeoutExtensions.WithTimeout[T](Task`1 task, TimeSpan timeoutDelay, String message)
  
     at Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task`1 baseUriTask, CancellationToken applicationStoppingToken, Boolean proxy404s)
  
     at Microsoft.AspNetCore.Builder.SpaProxyingExtensions.&lt;&gt;c__DisplayClass2_0.&lt;&lt;UseProxyToSpaDevelopmentServer&gt;b__0&gt;d.MoveNext()
  
  --- End of stack trace from previous location where exception was thrown ---
  
     at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
  
     at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
  </code></pre>
  
  <p>I have submitted the problem at: </p>
  
  <p><a href="https://developercommunity.visualstudio.com/content/problem/858687/failed-to-start-npm-ensure-that-npm-is-installed-a.html" rel="noreferrer">https://developercommunity.visualstudio.com/content/problem/858687/failed-to-start-npm-ensure-that-npm-is-installed-a.html</a></p>