'npm install' extremely slow on Windows

2020-02-17 08:43发布

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?

标签: windows npm
10条回答
Melony?
2楼-- · 2020-02-17 08:48

For me it appeared to be a problem with IPv6.

Disabling IPv6 helped immensely for me.
With IPv6 turned on "update-package newtonsoft.json" took 1:45 to time out with the error "update-package : A task was canceled."

With IPv6 disabled "update-package newtonsoft.json" completed in 10 seconds

查看更多
SAY GOODBYE
3楼-- · 2020-02-17 08:48

I tried all the config's (proxy, registry, etc) nothing worked for me, so did a complete uninstall and install node & npm. Which helped to solve the issue.

查看更多
Summer. ? 凉城
4楼-- · 2020-02-17 09:00

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.

查看更多
对你真心纯属浪费
5楼-- · 2020-02-17 09:00

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.

查看更多
▲ chillily
6楼-- · 2020-02-17 09:01

I know its just a workaround, but try using the build-in "Windows PowerShell"

查看更多
虎瘦雄心在
7楼-- · 2020-02-17 09:02

Turning off the Windows Defender Firewall helped for me.

Because it just doesnt feel right I first added the WIFI to a Private Network (via WIFI settings) and only turned off the Windows Defender for a Private Network instead of all public Networks.

The next step should be: what network traffic causes this and how to add this to the Windows Defender exception rule :)

查看更多
登录 后发表回答