Build android --prod causing heap out of memory error

Running the following code in Ionic 3 app …

ionic cordova build android --prod --release

causes the following “Allocation failed - JavaScript heap out of memory” error

[16:47:09]  copy finished in 29.74 s

<--- Last few GCs --->

[918:0x103000000]   158841 ms: Mark-sweep 1403.4 (1480.6) -> 1403.4 (1455.1) MB, 3368.9 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 3369 ms) last resort GC in old space requested
[918:0x103000000]   162589 ms: Mark-sweep 1403.4 (1455.1) -> 1403.4 (1455.1) MB, 3748.2 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x18f124a25ee1 <JSObject>
    1: setEmitFlags [/Users/obi/Projects/Mobile/MyApp/node_modules/typescript/lib/typescript.js:~49349] [pc=0x28ed3af9bb4b](this=0x18f12c4d0991 <Object map = 0x18f12fc2a269>,node=0x18f1576b6fb1 <IdentifierObject map = 0x18f195590e29>,emitFlags=16777216)
    3: createEntityNameFromSymbolChain(aka createEntityNameFromSymbolChain) [/Users/obi/Projects/Mobile/MyApp/node_modules/types...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/usr/local/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
 4: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
 5: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
 6: 0x28ed3a90463d
 7: 0x28ed3af9bb4b
Abort trap: 6

I’ve tried all the solutions I found in this forum (including adding --max-old-space-size=4096) but no luck. I’ve been Googling till kingdom come, but still no luck!

I can’t submit it to the Play Store until it’s resolved.

Any suggestions? Thanks.