'npm install' extremely slow on Windows

后端 未结 13 1685
面向向阳花
面向向阳花 2020-12-24 04:35

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 tryi

相关标签:
13条回答
  • 2020-12-24 04:45

    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.

    0 讨论(0)
  • 2020-12-24 04:46

    Make sure you really are using a recent version of npm. In my case C:\Program Files\nodejs\npm.cmd had been using an old npm-cli.js below the default prefix folder %appdata%\npm rather than a newer npm-cli.js below C:\Program Files\nodejs.

    Setting the environment variable npm_config_prefix to C:\Program Files\nodejs solved that. (Before finding that solution, I tried using the --prefix argument and found out the hard way doing so "forces non-global commands to run in the specified folder".)

    I found a huge performance increase going from 3.10.9 to 6.13.4-- enough to make npm install times acceptable despite interference from antivirus.

    0 讨论(0)
  • 2020-12-24 04:48

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

    0 讨论(0)
  • 2020-12-24 04:49

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

    0 讨论(0)
  • 2020-12-24 04:50

    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.

    0 讨论(0)
  • 2020-12-24 04:51

    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!

    0 讨论(0)
提交回复
热议问题