node.jsnpmyarnpkgmacos-big-sur

Why npm install speed so slow?


i am using mac book pro - M1 chip and bigsur

but I have a problem. the speed so slow when i install any library to npm

please click the picture i have counted


the picture, i had install the 'react-native-fast-image' but there consumes more 1000s for installed

likewise, i had typed in terminal, 'npm i or yarn install'

Consumes more than 30 minutes.


for solving this, i have tried deleted xcode, and webstrom, and vsc but, there are no change in speed.


Solution

  • I had this exact same issue. After speaking with Genius Bar we realised I was on an old version 12 of node. Node 15.5 onwards runs natively on M1 so isn't being parsed through Rosetta 2, which was likely causing the lag.

    You can check the version of node you're on by running node -v

    If you're on anything below 15, if you run nvm install v15 on terminal this might solve your issue by updating your node.

    I had an error at this point (you might not) saying:

    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
    missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    

    Which was solved with this.

    After sorting that, when running nvm install v15 it solved the lagginess :) good luck!

    You might also find even after installing the latest node, your terminal defaults to an old version (mine did to much bemusement!)

    You can solve it be setting a default, check this link.

    In short, run: nvm use node

    This switches to the latest installed version of node.