Nuxt build unbearably slow (AWS ubuntu served through nginx)

I'm a new developer trying to launch my own site (nuxtjs frontend, python fastapi backend) on aws ec2 ubuntu served through nginx.

Nuxt build takes unbearably long (more than 20 minutes) and I normally just cancel it cus i have no idea how long more it will take. (npm run dev runs normally for some reason)

20% of the time, my ubuntu instance starts hanging also and I have to stop it and restart (reboot doesn't work)

What could be some reasons why its taking so damn long and is there any way around this? I'm actually considering migrating from nuxt to something else just because it cannot even build on my ubuntu instance but that's my very last resort

pls help :(