
While developing a large React Native app using Expo, I ran into a crash that looked like this:
Android Bundling failed 29201ms node\_modules/expo-router/entry.js (2156 modules)
ERROR global.css: A jest worker process (pid=4320) was terminated by another process: signal=SIGTERM
This usually means that the Node.js process was killed due to out-of-memory conditions, especially during heavy bundling in complex projects, tracing this out took an eternity.
Before changing anything, check how much heap memory Node is using:
node -e "console.log((require('v8').getHeapStatistics().heap_size_limit / 1024 / 1024).toFixed(2) + ' MB')"
If it prints something around 2096.00 MB, then you're hitting the ~2GB default heap limit.
To temporarily increase heap size for the current terminal session:
export NODE_OPTIONS="--max_old_space_size=4096"
Then start your Expo app:
npx expo start
To make this permanent, add the export line to your shell config:
For Zsh:
echo 'export NODE_OPTIONS="--max_old_space_size=4096"' >> ~/.zshrc
source ~/.zshrc
For Bash:
echo 'export NODE_OPTIONS="--max_old_space_size=4096"' >> ~/.bashrc
source ~/.bashrc
You can verify the new limit with:
node -e "console.log((require('v8').getHeapStatistics().heap_size_limit / 1024 / 1024).toFixed(2) + ' MB')"
Expected output:
~4144.00 MB
PowerShell:
$env:NODE_OPTIONS="--max_old_space_size=4096"
npx expo start
Command Prompt:
set NODE_OPTIONS=--max_old_space_size=4096
expo start
Press Win + R, type sysdm.cpl, press Enter.
Go to the Advanced tab -> click Environment Variables.
Under User Variables, click New:
NODE_OPTIONS--max_old_space_size=4096Click OK, restart your terminal.
Verify with:
node -e "console.log((require('v8').getHeapStatistics().heap_size_limit / 1024 / 1024).toFixed(2) + ' MB')"
To avoid manually setting environment variables, add a start script:
"scripts": {
"start": "set NODE_OPTIONS=--max_old_space_size=4096 && expo start"
}
cross-env)Install the tool:
npm install --save-dev cross-env
Then in package.json:
"scripts": {
"start": "cross-env NODE_OPTIONS=--max_old_space_size=4096 expo start"
}
Once I increased the heap size, Expo bundling no longer crashed, and the Jest worker errors disappeared. This is a common issue for heavier Expo React Native apps, and adjusting the memory limit is an effective fix.
If you're hitting bundling crashes or random process kills during development, check your heap size - it might be the culprit.
– Mohammad