Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

hi everyone, when i ran ionic cordova build android --prod i get this error


PS C:\projects\AfaninWrie> ionic cordova build android --prod
> ionic-app-scripts build --prod --target cordova --platform android
[15:21:14]  ionic-app-scripts 3.2.0
[15:21:14]  build prod started ...
[15:21:14]  clean started ...
[15:21:14]  clean finished in 3 ms
[15:21:14]  copy started ...
[15:21:14]  deeplinks started ...
[15:21:14]  deeplinks finished in 98 ms
[15:21:14]  ngc started ...
[15:27:06]  ngc finished in 352.08 s
[15:27:06]  preprocess started ...
[15:27:06]  preprocess finished in 1 ms
[15:27:06]  webpack started ...
[15:27:07]  copy finished in 352.90 s
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF6400CEEE5
 2: 00007FF6400A8CD6
 3: 00007FF6400A96E0
 4: 00007FF640510D3E
 5: 00007FF640510C6F
 6: 00007FF64045C594
 7: 00007FF640452B67
 8: 00007FF6404510DC
 9: 00007FF64045A0B7
10: 00007FF64045A136
11: 00007FF64057F7B7
12: 00007FF6406587FA
13: 000001FCE0A5C6C1
[ERROR] An error occurred while running subprocess ionic-app-scripts.

        ionic-app-scripts build --prod --target cordova --platform android exited with exit code 134.

        Re-running this command with the --verbose flag may provide more information.

i tried every thing
i tried this solution

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\..\@ionic\app-scripts\bin\ionic-app-scripts.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node --max_old_space_size=4096  "%~dp0\..\@ionic\app-scripts\bin\ionic-app-scripts.js" %*
)

nothing change and i update typescript also i change ionic build
ionic build android --prod --release --max_old_space_size=4096
also tried this

    "ionic:build": "node --max-old-space-size=8192 --stack-size=1968 node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build"

this is my ionic info


Ionic:

   ionic (Ionic CLI)  : 4.1.2 (C:\Users\sofe9\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
Cordova Platforms     : android 7.0.0, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-webview 2.1.3, (and 6 other plugins)

System:

   Android SDK Tools : 26.1.1 (C:\Users\sofe9\.android\sdk)
   NodeJS            : v10.11.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.4.1
   OS                : Windows 10


1 Like

I have the same here, did you find the solution?

Yes i searched alot and what i get that —prod is not used anymore i think ionic delete it from them platform know you can just use

Ionic cordova build —release android

That what i get from there site

1 Like

but you just generate for android or did you tried for IOS too?

yes i tried put i got the same issue , but with ionic cordova build --release android i published them both

–prod is necessary, as it would minimize the app load time

I have the same problem. I agree with devsid, this is important.
Did anyone find a solution? Please share.

This one command helped me:
export NODE_OPTIONS=--max_old_space_size=8192