The issue can be resolved by allocating more memory with the --max-old-space-size
flag.
On Android, add the following to your build.gradle file:
project.ext.react = [
nodeExecutableAndArgs: ["node", "--max_old_space_size=8192"]
]
On iOS, in Xcode, select your target and go to the "Build Phases" tab, in the section "Bundle React Native code and images", add the flag to the shell script:
export NODE_BINARY='node --max_old_space_size=8192'
../node_modules/react-native/packager/react-native-xcode.sh