Blog

Aws-sdk, React-Native and JavaScript heap out of memory

JavaScript

When I try to use aws-sdk in React-Native app, I faced to JavaScript heap out of memory when trying to run my application. I passed almost five days searching over the internet to find a solution to my problem. I remarked that this problem was general and most people have it.

Among all solutions that I try, only one solves my problem. It’s time to show you which. I use react 17.0.2 and react-native 0.65.1.

Illustration from the article: Aws-sdk, React-Native and JavaScript heap out of memory

The previous image shows the structure of my react native project. To solve our issue caused by aws-react-native.js, we must ignore it in Babel config.

To do that, we just open file babel.config.js and append this in babel configuration:

“ignore”: [“./aws-sdk-js/dist/aws-sdk-react-native.js”]

In your case, you must change the path ./aws-sdk-js/dist/aws-sdk-react-native.js with the path of the file you want to ignore. If your file is located in node_modules, you must write like this:

“ignore”: [“node_modules/aws-sdk-js/dist/aws-sdk-react-native.js”]

this complete babel configuration is:

    module.exports = {
    presets: [‘module:metro-react-native-babel-preset’],
    “ignore”: [“./aws-sdk-js/dist/aws-sdk-react-native.js”]
    };

babel.config.js

babel.config.js

I hope this manipulation will work for you and save you time.