wasp icon indicating copy to clipboard operation
wasp copied to clipboard

Wasp on WSL: npm install is sometimes super slow?

Open Martinsos opened this issue 6 months ago • 12 comments
trafficstars

We had a couple of people say that Wasp's npm install is super slow on WSL for them. Something like 40 minutes and more, which is ridiculous. I am guessing this happens only in certain setups or we would hear more about it. Maybe it has to do with them running it on Win vs Linux filesystem, which is a common mistake? Or how they have WSL set up?

Let's track this here!

Martinsos avatar May 02 '25 13:05 Martinsos

Win vs Linux filesystem, which is a common mistake

I think we should have a check+warning for this in the compiler. (related #1857)

cprecioso avatar May 02 '25 13:05 cprecioso

Possibly related: #2262

sodic avatar May 02 '25 14:05 sodic

I helped a user earlier today that had a super slow npm i by just asking them to upgrade to the latest npm (npm i -g npm) and it did speed up their install. Discord

cprecioso avatar May 02 '25 14:05 cprecioso

When I started using Wasp I started running it on Windows instead of Linux file system.

At that time the hot reload didn't work (I had to do ctrl+c and wasp start to see changes) and when installing the OpenSaaS template dependencies, it took me up to 40-50 minutes.

When I moved Wasp to the Linux filesystem the hot reload started working and the installation time was much less.

I've cheched now that my Laptop took 19 min to npm install a new OpenSaaS Template.

OS: W10 (WSL2) CPU: 8C/16T RAM: 16GB Download speed: ~350Mbps

NeroxTGC avatar May 02 '25 17:05 NeroxTGC

When I started using Wasp I started running it on Windows instead of Linux file system.

At that time the hot reload didn't work (I had to do ctrl+c and wasp start to see changes) and when installing the OpenSaaS template dependencies, it took me up to 40-50 minutes.

When I moved Wasp to the Linux filesystem the hot reload was working and the installation time was much less.

I've cheched now that my Laptop took 19 min to npm install a new OpenSaaS Template.

OS: W10 (WSL2) CPU: 8C(16) RAM: 16GB Download speed: ~350Mbps

Thanks @NeroxTGC , this helps a lot! Ah yes, Windows file system would explain that.

When you say that your laptop took 19 mins to npm install a new OpenSaaS template -> is that how long it takes now that you run it on WSL but on Linux file system, or is this the time it took before when you were doing it on Windows file system?

Martinsos avatar May 02 '25 19:05 Martinsos

@Martinsos This is how long it takes me now with the Linux filesystem.

NeroxTGC avatar May 02 '25 19:05 NeroxTGC

It seems it might be related to network issues and not disk issues. Setting a new DNS seems to solve the issue in some cases:

  • https://www.reddit.com/r/bashonubuntuonwindows/comments/nt8asc/comment/hk7zpbw/
  • https://github.com/microsoft/WSL/issues/7254#issuecomment-905767204

cprecioso avatar May 05 '25 09:05 cprecioso

It seems it might be related to network issues and not disk issues. Setting a new DNS seems to solve the issue in some cases:

Oh interesting, @NeroxTGC if you happen to have time to try this out, would be great, so we can know if this helps.

Martinsos avatar May 05 '25 14:05 Martinsos

First of all I will try updating my npm version, now is: v10.7.0

Ok, It took the same time with the latest LTS version: v22.15.0 (19 min)

Next, after testing the solution of:

in wsl, type below.

sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'
sudo chattr +i /etc/resolv.conf

After that, type below in cmd with administrator.

wsl --shutdown

It took the same time, 19 min.

btw the solution message also says:

Did 4 reboots - works as expected.

And some mention about disabling IPv6

So I will try that and reboot a few times.

NeroxTGC avatar May 06 '25 11:05 NeroxTGC

Uff! Ok thanks a lot @NeroxTGC for trying all this, that helps.

Martinsos avatar May 06 '25 12:05 Martinsos

No news from my side, I have not managed to reduce the time.

NeroxTGC avatar Jun 02 '25 06:06 NeroxTGC

Related: https://github.com/wasp-lang/wasp/issues/2331 .

Martinsos avatar Jun 13 '25 12:06 Martinsos