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

Created on 8 Jan 2020  Â·  16Comments  Â·  Source: dotnet/aspnetcore

_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 [email protected] 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.
    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.))

 ---> 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.)

 ---> 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.

 ---> 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)

area-mvc investigate

Most helpful comment

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

All 16 comments

Hi. Thanks for contacting us.
We're closing this issue as there was not much community interest in this ask for quite a while now.
You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

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

+1

+1

+100500

+1

+1

+1

+1

+1

Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

+1

any news on that or at least any workaround.

Working on a project using core 2.2 + angular and can't get passe that issue not matter what I'm trying

I did manage to fix this issue by removing everything from PATH, and adding manualy only related to npm.
Seems to me some Windows issue with PATH variable

I forgot to mention I'm using core 2.2 and I'm on linux. Also one specificity.
Im using nvm to manage multiple version of node.

But:

I don;t have the issue on my windows vm
if I run via terminal dotnet run command it's working

But as soon Im trying to debug it I run into that issue.

If I type npm command in a random terminal it can find it.
If I print my PATH variable I can see nvm path to node or I tried to manually add npm path and still the same issue

We don't think there is a product issue here.

There seems to be multiple different reports lined up in the issue, if you still experience problems in a different environment than the original issue, please file a separate issue.

Please, note that some versions mentioned here are out of support as per our support policy, so we recommend moving to a supported version first. (2.1, 3.1 or 5.0)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markrendle picture markrendle  Â·  3Comments

bgribaudo picture bgribaudo  Â·  3Comments

Kevenvz picture Kevenvz  Â·  3Comments

ipinak picture ipinak  Â·  3Comments

rbanks54 picture rbanks54  Â·  3Comments