Skip to main content
All CollectionsBuildReact Native
React Native build fails with "FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory"
React Native build fails with "FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory"

Too many dependencies and not enough allocated memory.

Jihye E avatar
Written by Jihye E
Updated over 6 years ago

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
Did this answer your question?