Reached heap limit Allocation failed - JavaScript heap out of memory nodejs
create swap memory
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-memory-swap-file/
After that set the environment variable
export NODE_OPTIONS=--max_old_space_size=4096