'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条回答
Ridiculous、
2楼-- · 2020-02-17 09:07

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.

Concerns regarding security : hopefully you know what you download to your node_modules folder, do you ;)

查看更多
smile是对你的礼貌
3楼-- · 2020-02-17 09:07

Turning off Windows Firewall and Windows Defender Real-time protection did it for me in Windows 10.

查看更多
干净又极端
4楼-- · 2020-02-17 09:08

I faced the same issue while creating project while using angular cli "ng new PROJECT_NAME" this command triggers "npm -install" after creation of project, which took too long to install, and got stuck at "Installing packages for tooling via npm" . Follow these which worked for me

1) Check your npm version "npm --version" (must be higher than 2.1.8)Update your npm package by "npm -g install --save latest-version"

2) Remove the progress bar which consumes more time "npm set progress=false"

check this issues if still doesn't fix your problem https://github.com/nodejs/node/issues/4150 https://github.com/npm/npm/issues/11283

Hopefully this sorts the problem Cheers!

查看更多
Lonely孤独者°
5楼-- · 2020-02-17 09:13

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

查看更多
登录 后发表回答