IONIC 2 --prod --release build failing

When i run ionic build android --prod --release

i get a failure see below at end of scripts (THis only happens on my macbook but not on my windows) any ideas? i am on ionic 2.2.0.

Note this has been working fine for a month now it just started breaking yesterday… no idea why

12:57:25] ionic-app-scripts 1.1.4
[12:57:25] build prod started …
[12:57:25] clean started …
[12:57:25] clean finished in 4 ms
[12:57:25] copy started …
[12:57:25] ngc started …
[12:57:42] ngc finished in 17.17 s
[12:57:42] preprocess started …
[12:57:42] optimization started …
[12:57:43] copy finished in 17.61 s
[12:57:59] optimization finished in 16.59 s
[12:57:59] preprocess finished in 16.59 s
[12:57:59] webpack started …
[12:58:41] webpack finished in 42.28 s
[12:58:41] sass started …
[12:58:41] transpile bundle started …
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
** 1:**
<— Last few GCs —>

97800 ms: Mark-sweep 1327.6 (1426.7) -> 1315.8 (1428.7) MB, 851.4 / 0.0 ms [allocation failure] [GC in old space requested].
98672 ms: Mark-sweep 1315.8 (1428.7) -> 1315.8 (1429.7) MB, 871.8 / 0.0 ms [allocation failure] [GC in old space requested].
99653 ms: Mark-sweep 1315.8 (1429.7) -> 1315.8 (1395.7) MB, 981.7 / 0.0 ms [last resort gc].
100544 ms: Mark-sweep 1315.8 (1395.7) -> 1315.8 (1395.7) MB, 890.7 / 0.0 ms [last resort gc].

<— JS stacktrace —>

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

Security context: 0x144b9a9cfb51
1: stringify [native json.js:178] [pc=0x340c28e519d7] (this=0x3c24e5d884d9 <an Object with map 0x7b295c75119>,E=0x36c559b12459 <an Object with map 0x28b729a95a39>,F=0x144b9a904381 ,S=0x144b9a904381 )
2: arguments adaptor frame: 1->3
3: getText [/Users/saulabiuakinlolu/Documents/testmobileui/node_modules/typescript/lib/typescript.js:35629] [pc=0x340c29051241]…

node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Localv8::Value, v8::Localv8::Message) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::factory::NewRawOneByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
5: v8::internal::String::SlowFlatten(v8::internal::Handlev8::internal::ConsString, v8::internal::PretenureFlag) [/usr/local/bin/node]
6: v8::internal::BasicJsonStringifier::SerializeString(v8::internal::Handlev8::internal::String) [/usr/local/bin/node]
7: v8::internal::BasicJsonStringifier::Result v8::internal::BasicJsonStringifier::Serialize_(v8::internal::Handlev8::internal::Object, bool, v8::internal::Handlev8::internal::Object) [/usr/local/bin/node]
8: v8::internal::BasicJsonStringifier::Result v8::internal::BasicJsonStringifier::Serialize_(v8::internal::Handlev8::internal::Object, bool, v8::internal::Handlev8::internal::Object) [/usr/local/bin/node]
9: v8::internal::Runtime_BasicJSONStringify(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
10: 0x340c261092a7

What version of ionic-app-scripts are you using?

{
  "name": "",
  "author": "",
  "homepage": "",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve",
    "lint": "ionic-app-scripts lint"
  },
  "dependencies": {
    "@angular/common": "2.4.8",
    "@angular/compiler": "2.4.8",
    "@angular/compiler-cli": "2.4.8",
    "@angular/core": "2.4.8",
    "@angular/forms": "2.4.8",
    "@angular/http": "2.4.8",
    "@angular/platform-browser": "2.4.8",
    "@angular/platform-browser-dynamic": "2.4.8",
    "@angular/platform-server": "2.4.8",
    "@ionic-native/android-fingerprint-auth": "^3.5.0",
    "@ionic-native/core": "^3.3.0",
    "@ionic-native/file": "^3.3.0",
    "@ionic-native/file-opener": "^3.3.0",
    "@ionic/storage": "2.0.0",
    "@types/filesaver": "0.0.30",
    "crypto-js": "^3.1.9-1",
    "file-saver": "^1.3.3",
    "ionic-angular": "2.2.0",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "ng2-pdf-viewer": "^1.0.2",
    "rxjs": "5.0.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.7.2"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.1.4",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-inappbrowser",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard",
    "cordova-plugin-touch-id",
    "cordova-plugin-device",
    "cordova-plugin-file",
    "cordova-plugin-file-opener2",
    "cordova-plugin-console",
    "cordova-plugin-android-fingerprint-auth"
  ],
  "cordovaPlatforms": [
    "ios",
    {
      "platform": "ios",
      "version": "",
      "locator": "ios"
    }
  ],
  "config": {
    "ionic_source_map": "source-map"
  },
  "description": ""
}

You’re using a pretty old version, and I know around the time of your version people started running into this issue. I’d update it to the latest, which at the moment is 1.3.6

2 Likes

Will it work with the ionic version i am on? also how do i update app scripts? do i just change the version number in my package.json and re-run the npm install

Ignore that question it worked :slight_smile: thank you !!

I changed your post to format your code or error message correctly. Please use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.

1 Like

How u resolved that issue, i tried with many ways like –max-old-space-size=2048, but none of the answers solved my issue,i am using ionic/app-scripts": “^3.1.9” with angular: “5.2.10”, please sought out from this problem

1 Like