This does not sound like an Automation API specific issue. A couple of general suggestions that might help:
1. Try bumping the resources allocated to the VM. How much RAM have you allocated? Try doubling perhaps?
2. If (1) isn't possible, you could build docker images with the node projects already cloned and installed in the image and instead use
LocalSource
variants of automation API.