
Let's say you are using the yarn CLI to install packages and the CLI stdout hangs during Resolution step, perhaps something like this.
~]$ yarn install
➤ YN0000: · Yarn 4.4.1
➤ YN0000: ┌ Resolution step
➤ YN0000: ⠧ node-int64@npm:^0.4.0
I ran into this on an Amazon Web Services (AWS) EC2 instance that didn't have much memory. It was a t2.micro instance with 1G of memory.
~]$ free -h
total used free shared buff/cache available
Mem: 949Mi 356Mi 403Mi 8.0Mi 189Mi 439Mi
Swap: 0B 0B 0B
And the instance was reaching 100% used CPU during the yarn install.

One option would be to temporarily or permanently update the instance type to an instance with more CPU and memory. Of course, a bigger instance will cost more than a smaller instance.

For example, upgrading my EC2 instance to t2.medium had about 4GB of memory.
~]$ free -h
total used free shared buff/cache available
Mem: 3.8Gi 310Mi 3.1Gi 9.0Mi 446Mi 3.3Gi
Swap: 0B 0B 0B
Or following the answer on this stackoverflow.com post, as root, I gave my EC2 instance 4GB of swap memory.
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon --show
And verified there was indeed 4GB of swap memory.
~]$ free -h
total used free shared buff/cache available
Mem: 949Mi 293Mi 438Mi 8.0Mi 217Mi 502Mi
Swap: 4.0Gi 0B 4.0G
Did you find this article helpful?
If so, consider buying me a coffee over at