Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 471
rudenick Avatar asked Dec 02 '22 08:12

rudenick


1 Answers

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.

like image 115
ironmongrrrl Avatar answered Dec 04 '22 04:12

ironmongrrrl