There is two solution for this problem.
- increase server ram
- create dummy swap memeory
- This error occurs when the memory allocated for the executing application is less than the required memory. By default, the memory limit in Node.js is 512 MB.
first approach is totally server-administrator work
second approach
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
Execute this 3 line code to create 1gb swap memory. which will work as your virutal ram.
third approach to increase this amount, you need to set the memory limit argument —-max-old-space-size. It will help avoid a memory limit issue.
execute this line of code each time you before you build your project
This error occurs when the memory allocated for the executing application is less than the required memory. By default, the memory limit in Node.js is 512 MB. To increase this amount, you need to set the memory limit argument —-max-old-space-size. It will help avoid a memory limit issue.
node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb
more details for node-max-old-space