2

Everything I do with NPM takes several minutes; especially npm install, even if I already have all the packages installed. I first thought the problem is that the old code I am working with just takes longer to update (because last time an older npm version was used) but the problem percists even if I repeat the process.

My system and other Information:

  • Windows 11 PC
  • Ubuntu 18.04.5 VM from the Microsoft Store
  • VS Code.
  • npm version 8.19.2
  • node version 16.17.0
  • From my package-lock.json file: "lockfileVersion": 2
  • I usally have 5 to 10 dependecies listed in my package file
  • My internet speed is around 25 MB/s

What I tried so far with no luck:

  • A newer Version of Ubuntu
  • Using http instead of https a la:
npm config set registry http://registry.npmjs.org/ --global

as was suggested in 'npm install' extremely slow on Windows. It seems to me it still tries to connect to the https address (at least that's what it looks like if I use npm install --verbose to show more feedback).

No matter what I still sit here, wasting ages waiting for my npm install.

melon_lord
  • 63
  • 8
  • Which version of node and npm are you using? Does your package have a shrinkwrap or lock file? If so, what is the version of the file? (eg: `"lockfileVersion": 2,`) And finally, how many packages are you downloading with `npm install` and what's your internet connection speed? – ant Sep 19 '22 at 16:26
  • It can also depend on hardware specs – Konrad Sep 19 '22 at 16:36
  • @ant npm version 8.19.2, node version 16.17.0, from my package-lock.json file: "lockfileVersion": 2, I usally have 5 to 10 dependecies listed in my package file, My speed is around 25 MB/s – melon_lord Sep 19 '22 at 16:37
  • Have you tried installing Node.js/npm natively on Windows to see if that speeds things up? – robertklep Sep 20 '22 at 17:43
  • I started with that using the Windows shell but then certain packages would have no compatibility with windows. Or is there a better way? – melon_lord Sep 26 '22 at 13:13

1 Answers1

1

I finaly found a solution. I just did not now to ask the right question.

The problem was that I was using WSL version 2 and my files are in C: and not the Ubuntu folders. A fix that worked for me was moving to WSL version 1.

More details can be found here.

If you're also switching to WSL version 1 and are having problems with node or npm, this might help.

melon_lord
  • 63
  • 8