Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'npm install' extremely slow on Windows

For me is npm install extremely slow. I'm using Windows 8.1 with the latest npm version. My connection speed is around 100Mbit/s.

The project I'm trying to install has around 20 packages/dependencies and it takes around 30 Minutes to install all dependencies ...

Does anyone have a clue?

like image 505
Simon Knittel Avatar asked Apr 01 '15 15:04

Simon Knittel


People also ask

Why npm install is slow in Windows?

It seems like npm do not deal well with internet connections and can sometimes end in such situation. 1) I'll advice you to check if your firewall or antivirus is not performing any scan or filtering which may slow down npm install. 2) You may also use caching from npm like below.

Why is my npm install taking so long?

If you find that npm is running slow and it isn't your computer or internet, it is most likely because of a severely outdated version.

How long does npm install usually take?

it takes ~5 minutes to download and install.


2 Answers

I ran into the same problem, using --verbose as peterh mentioned showed me the source of the problem: I am behind a proxy, which uses its own certificates for https-connections. According to user "Mletter1" on https://github.com/npm/npm/issues/8872 the issue is quite easily solved by using http:

npm config set registry http://registry.npmjs.org/ --global 

And voilà, it's fast again. Of course you should only do this, if you're ok with cleartext npm infos over the net ;-)

like image 55
Christof Kälin Avatar answered Sep 20 '22 13:09

Christof Kälin


Warning regarding security: this is an insecure approach if you don't use any other means of antivirus protection.

From eternity → to 5 seconds builds:

  • search for Windows Defender settings
  • → Virus & threat protection
  • → Virus & threat protection Settings
  • → Exclusions

here add this two paths to your list of excluded realtime protection folders:

C:\Program Files\nodejs C:\Users\<your username>\AppData\Roaming\npm 

PS: replace the <your username> with your respective User folder name.
If you're wandering why you can't find the AppData folder in Explorer, make sure to check View options for hidden folders.

like image 35
Roko C. Buljan Avatar answered Sep 20 '22 13:09

Roko C. Buljan