Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm is very slow on Windows 10

This question is basically a duplicate of this one, except that the accepted answer on that question was, "it's not actually slower, you just weren't running the timing command correctly."

In my case, it actually is slower! :)

I'm on Windows 10. Here's the output from PowerShell's Measure-Command (the TotalMilliseconds line represents wall-clock time):

PS> Measure-Command {npm --version}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 1
Milliseconds      : 481
Ticks             : 14815261
TotalDays         : 1.71472928240741E-05
TotalHours        : 0.000411535027777778
TotalMinutes      : 0.0246921016666667
TotalSeconds      : 1.4815261
TotalMilliseconds : 1481.5261

A few other numbers, for comparison:

  • '{.\node_modules.bin\mocha}': 1300ms
  • 'npm run test' (just runs mocha): 3300ms
  • npm help: 1900ms.
  • the node interpreter itself is ok: node -e 0: 180ms

It's not just npm that's slow... mocha reports that my tests only take 42ms, but as you can see above, it takes 1300ms for mocha to run those 42ms of tests!

like image 796
Josh Avatar asked Nov 15 '16 23:11

Josh


1 Answers

I've had the same trouble. Do you have Symantec Endpoint Protection? Try disabling Application and Device Control in Change Settings > Client Management > General > Enable Application and Device Control.

(You could disable SEP altogether; for me the command is: "%ProgramFiles(x86)%\Symantec\Symantec Endpoint Protection\smc.exe" -stop.)

If you have some other anti-virus, there's likely a way to disable it as well. Note that closing the app in the Notification area might not stop the virus protection. The problem is likely with any kind of realtime protection that scans a process as it starts. Since node and git are frequently-invoked short-running processes, this delay is much more noticeable.
In Powershell, I like to measure the performance of git status, both before and after that change: Measure-Command { git status }

like image 115
Patrick Szalapski Avatar answered Nov 20 '22 00:11

Patrick Szalapski