DEV Community

neta meta
neta meta

Posted on

Running our of memory when running `react-scripts build` on bitbucket pipline

Running our of memory when running react-scripts build on bitbucket pipline even with size=2 and a 3070MBx2 memory allocated = that means a little over 6gb of memory and its still not enough to build the script.

So far i've tried the following:

So far the only thing that worked was either removing big packages or adding: cross-env GENERATE_SOURCEMAP=false to my run script. which is not ideal because I want source maps.

Logs from bitbucket

> react-scripts --max_old_space_size=6000 build
Creating an optimized production build...
The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xxxxxx0.1.0 build: `react-scripts --max_old_space_size=6000 build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the xxxxxx0.1.0 @0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-07-08T17_05_53_040Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1
2021-07-08T17:05:53.326849634Z stdout P 
Enter fullscreen mode Exit fullscreen mode

Would love some help.

Discussion (3)

Collapse
rayvikram profile image
rayvikram

Not sure if bitbucket have option for self hosted runner. But GitHub have, and you can use any VM Or your own personal laptop for GitHub builds.

Collapse
netameta profile image
neta meta Author

That's not really a solution to this problem.

Collapse
rayvikram profile image
rayvikram

Agree. If nothing works then I think this will be helpful.