Another non-angular answer (I was facing the same issue building a react app on AWS Amplify).
As mentioned by Emmanuel it seems that it comes from the difference in the way memory is handled by node v10 vs node v12.
I tried to increase memory with no avail. But using node v12 did it.
Check how you can add nvm use $VERSION_NODE_12
to your build settings as explained by richard
frontend: phases: preBuild: commands: - nvm use $VERSION_NODE_12 - npm ci build: commands: - nvm use $VERSION_NODE_12 - node -v - npm run-script build