I’m using NPM to build my application, but the builds keeps failing. It looks like the process gets killed because of out of memory.
How do I limit the amount of memory NPM takes?
I’m using NPM to build my application, but the builds keeps failing. It looks like the process gets killed because of out of memory.
How do I limit the amount of memory NPM takes?
The build container is currently limited to 2GB of memory, regardless of the plan you are on.
This will be changed in the near future, but meanwhile, you can limit the amount of memory NPM uses by changing the NODE_OPTIONS
via your .platform.app.yaml
file.
variables:
env:
NODE_OPTIONS: --max_old_space_size=1536
Some useful keywords here: webpack, react, create-react-app, react-scripts build
Error message: 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.
@matthias-van-woensel Is the build container still limited to 2GB of memory?
Because I’m facing the same issue, even limiting the amount of memory NPM uses for the above example.
Are there another possible solutions to try to apply?
It currently still is yes. We are working on an alternative. But that’s not ready yet.
Could you try with yarn? Does that give better results?
Reach out to the support team to get some additional help.
Would you kindly share insight on how the support team fixed this issue? We have the same exact problem and various support reps have been trying to fix it, albeit unsuccessfully. Same exact results with yarn and npm.
yarn run production
yarn run v1.22.19
$ NODE_ENV=production webpack
Killed
error Command failed with exit code 137.
It means you are running out of memory on the build container. Have a look at the amount of memory your build is taking locally. If it is more than 2GB, it won’t currently work.
Might be best to make a support ticket to get a support agent to look at your project specifics.
Thank you for letting me know. Yes I do see webpack spikes to 1.98GB, and with the memory required by other concurrent node scripts and VSCode, I imagine it’s tipping the scales enough to cause the process to be killed on the server.
I appreciate the help.