'npm install' extremely slow on Windows
Solution 1:
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 ;-)
Solution 2:
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.
Solution 3:
I know its just a workaround, but try using the build-in "Windows PowerShell"
Solution 4:
I've been facing the same issue for a while. I was trying out the following
npm i typescript live-server --save-dev
The install would get stuck at it forever. However adding the -verbose flag worked just fine.
Solution 5:
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.
npm install package-name --cache "c:\path\to\use\as\dependencies\cache"
this will allow npm download and cache dependencies in the directory you specified.
3) another solution for caching npm packages dependencies is npm lazy, you may find more information about this at npm Lazy website
Note: the caching process may or may not improve the download speed but it will probably save downloads time when installing or updating your npm packages.