Next.js build worker exited with code: null and signal: SIGKILL

Next.js build worker exited with code: null and signal: SIGKILL

1. Check Available Memory

Check disk space first:
df -h /
Verify Swap: 
free -h

2. Add Swap Space (Recommended for Low-Memory VPS)

fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab

Explanation:

  • fallocate -l 2G /swapfile — creates a 2GB swap file.
  • chmod 600 /swapfile — secures the swap file.
  • mkswap /swapfile — sets up the file as swap.
  • swapon /swapfile — enables swap immediately.
  • The echo line ensures swap is enabled after reboot.

 

3. Try Building Again

npm run build
 
If the build succeeds, restart your service