aspnetcore: Failed to start 'npm': Ensure that 'npm' is installed and can be found in one of the PATH directories.

This issue has been moved from a ticket on Developer Community.


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:

Failed to start ‘npm’: Ensure that ‘npm’ is installed and can be found in one of the PATH directories.

In the System Environment Variables, Path includes C:\Program Files\nodejs and C:\Users\me\AppData\Roaming\npm amongst others.

Entering ‘npm’ in the VS 2019 Package Manager Console produces no errors and finishes with npm@6.12.1 C:\Program Files\nodejs\node_modules\npm.

The InnerException on the page includes:

System.ComponentModel.Win32Exception (267): The directory name is invalid.

This error has been documented and marked as resolved at:

https://github.com/aspnet/AspNetCore/issues/6342

But I’m still having the problem with VS 2019…

Any ideas how to resolve this?

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. <span class=hljs-keyword>Current</span> <span class=hljs-keyword>PATH</span> enviroment <span class=hljs-keyword>variable</span> <span class=hljs-keyword>is</span>: C:\Program Files (x86)\Intel\iCLS <span class=hljs-keyword>Client</span>;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® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Intel\Intel® 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 <span class=hljs-keyword>update</span> your PATH.

[2] See the InnerException for further details of the cause.))

—> 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. <span class=hljs-keyword>Current</span> <span class=hljs-keyword>PATH</span> enviroment <span class=hljs-keyword>variable</span> <span class=hljs-keyword>is</span>: C:\Program Files (x86)\Intel\iCLS <span class=hljs-keyword>Client</span>;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® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Intel\Intel® 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 <span class=hljs-keyword>update</span> your PATH.

[2] See the InnerException for further details of the cause.)

—> 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. <span class=hljs-keyword>Current</span> <span class=hljs-keyword>PATH</span> enviroment <span class=hljs-keyword>variable</span> <span class=hljs-keyword>is</span>: C:\Program Files (x86)\Intel\iCLS <span class=hljs-keyword>Client</span>;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® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Intel\Intel® 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 <span class=hljs-keyword>update</span> your PATH.

[2] See the InnerException for further details of the cause.

—> 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.<>c.<Attach>b__2_0(Task`1 task)

at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()

at System.Threading.Tasks.Task.<>c.<.cctor>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& 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.<>c__DisplayClass2_0.<<UseProxyToSpaDevelopmentServer>b__0>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)


Original Comments

Visual Studio Feedback System on 12/17/2019, 07:04 PM:

Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2017#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.


Original Solutions

(no solutions)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

+1 Still a problem. If you need community interest.