Ionic-app-scripts: Error in ionic cordova build android --prod

Created on 4 Jul 2017  路  14Comments  路  Source: ionic-team/ionic-app-scripts

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Error when running command: ionic cordova build android --prod

Note: that ionic build android, ionic run android and ionic serve all works fine.

I've read many topics that says once the project gets bigger, it stops working.

_It was working the day before issue arrive. It stopped working as we added more files and JSON for translation of app in multi-language._

Is it a known issue? Is there any solution?

Attached Image:
Errror:
capture

Ionic Info:
ionic info

Most helpful comment

same issue here

<--- Last few GCs --->

[16568:0x102801c00]   535124 ms: Mark-sweep 1403.7 (1870.8) -> 1403.7 (1870.8) MB, 912.9 / 0.0 ms  allocation failure GC in old space requested
[16568:0x102801c00]   535952 ms: Mark-sweep 1403.7 (1870.8) -> 1403.5 (1812.8) MB, 826.9 / 0.0 ms  last resort
[16568:0x102801c00]   536772 ms: Mark-sweep 1403.5 (1812.8) -> 1403.5 (1797.3) MB, 818.9 / 0.0 ms  last resort


<--- JS stacktrace --->

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

Security context: 0x36e293da9891 <JS Object>
    1: push(this=0x101ed1b20c01 <JS Array[50855]>)
    2: add(aka MappingList_add) [/Users/fan2net/Documents/truemerger/xincaidong/node_modules/source-map/lib/mapping-list.js:55] [pc=0x28a07b59313](this=0x101ed1b20bd1 <a Mappi
ngList with map 0x1e2b5e202621>,aMapping=0x2ee15c833e49 <an Object with map 0x10fc4835aa99>)
    3: addMapping(aka SourceMapGenerator_addMapping) [/Users/fan2net/Documents...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 6.5.0
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.12
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : ios 4.2.1
Ionic Framework                 : ionic-angular 3.2.1

System:

Node       : v8.1.2
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.1
ios-sim    : 5.0.13
npm        : 5.0.3

All 14 comments

same issue here

<--- Last few GCs --->

[16568:0x102801c00]   535124 ms: Mark-sweep 1403.7 (1870.8) -> 1403.7 (1870.8) MB, 912.9 / 0.0 ms  allocation failure GC in old space requested
[16568:0x102801c00]   535952 ms: Mark-sweep 1403.7 (1870.8) -> 1403.5 (1812.8) MB, 826.9 / 0.0 ms  last resort
[16568:0x102801c00]   536772 ms: Mark-sweep 1403.5 (1812.8) -> 1403.5 (1797.3) MB, 818.9 / 0.0 ms  last resort


<--- JS stacktrace --->

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

Security context: 0x36e293da9891 <JS Object>
    1: push(this=0x101ed1b20c01 <JS Array[50855]>)
    2: add(aka MappingList_add) [/Users/fan2net/Documents/truemerger/xincaidong/node_modules/source-map/lib/mapping-list.js:55] [pc=0x28a07b59313](this=0x101ed1b20bd1 <a Mappi
ngList with map 0x1e2b5e202621>,aMapping=0x2ee15c833e49 <an Object with map 0x10fc4835aa99>)
    3: addMapping(aka SourceMapGenerator_addMapping) [/Users/fan2net/Documents...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 6.5.0
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.12
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : ios 4.2.1
Ionic Framework                 : ionic-angular 3.2.1

System:

Node       : v8.1.2
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.1
ios-sim    : 5.0.13
npm        : 5.0.3

+1

It's been more than a month, does anyone have an answer to at least those 2 questions?

  • Is it a known issue?
  • Is there any solution?

Happens for me too

ionic info

Your system information:

ordova CLI: 6.5.0
Ionic Framework Version: 3.5.2
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 2.0.2
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.9.4
Xcode version: Not installed

A guy posted this in another issue and it works for now, but it should probably be documented as a limitation.

  1. add this to the package.json scripts
    "ionic:build": "node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build",

  2. run the command:
    npm run ionic:build --prod

  3. run the commands:

cordova build android --release
cordova build ios --release

There seems to be a memory leak in webpack when using the module concatination plugin and source maps. I got rid of the memory issues by setting ionic_source_map_type to cheap-source-map

in package.json worked for me:

  "config": {
    "ionic_source_map_type": "cheap-source-map"
  }

Please keep in mind that this will skip source maps for dev builds as well. We can make a custom webpack config file as workaround.

For more information, check out https://github.com/ionic-team/ionic-app-scripts#overriding-config-files

capture errpr build

help me please

I still need a solution for this. I'm able to run it locally following the steps provided, but on my CI I can麓t change from ionic cordova build ... --prod to npm run ionic:build

Update the dev dependency @ionic/app-scriptsto 3.1.9 and build correctly.

@nandyx it is not building even if i give him 8 Gb of ram it consume it and no build is released.... why we we separate everywhere

ionic cordova build --release

and

ionic cordova build --release --prod --aot

I think this is the command we are looking for my build was becoming 1.4 from 9 before something crashes and i cannot rebuild...

I try to install 8.9.0 8.9.4 10.0.0 node and reinstall all ionic and cordova packages nothing works....

You can try:
For iOS:

"node --max-old-space-size=8192 /usr/local/bin/ionic cordova build ios --prod"

image

Similar for Android:

"node --max-old-space-size=8192 /usr/local/bin/ionic cordova build android --prod"

@raghav-khunger this solution is not working everywhere.And the bundler isn't suppose to use 8 + GB of ram :)

@Stradivario Well, for me adding that 8GB indicator worked and I was able to build it.

Was this page helpful?
0 / 5 - 0 ratings