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:
- added
max_old_space_size=6000
to build script (react-scripts --max_old_space_size=6000 build
) - adding
"resolutions": { "eslint-webpack-plugin": "2.3.0"}
to my package.json(https://github.com/facebook/create-react-app/issues/10119#issuecomment-734184155) - added
"devDependencies": { "@babel/core": "^7.7.7",
to my package.json(https://github.com/facebook/create-react-app/issues/8096#issuecomment-571717268)
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
Would love some help.
Top comments (3)
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.
That's not really a solution to this problem.
Agree. If nothing works then I think this will be helpful.