6

I am using Ionic to build for Android and I am always getting this error:

ionic error

I have this from ionic info:

ionic info

Make no mistake, I have browsed the whole internet finding solutions but I am not successful.
I have seen and read the following:

I also observed that I have this unique error compared to the others:

Security context: 000001F502E3FA99 <JS Object>     
    1: createLiteral [..]    
    2: typeToTypeNodeHelper(aka typeToTypeNodeHelper) [..]

I have been stuck for over 2 days on this and I really need help and guidance on this.

Here is my package.json content:

{
    "name": "project",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "5.2.10",
        "@angular/compiler": "5.2.10",
        "@angular/compiler-cli": "5.2.10",
        "@angular/core": "5.2.10",
        "@angular/forms": "5.2.10",
        "@angular/http": "5.2.10",
        "@angular/platform-browser": "5.2.10",
        "@angular/platform-browser-dynamic": "5.2.10",
        "@ionic-native/camera": "^4.5.2",
        "@ionic-native/core": "4.4.0",
        "@ionic-native/file": "^4.7.0",
        "@ionic-native/file-chooser": "^4.7.0",
        "@ionic-native/file-path": "^4.7.0",
        "@ionic-native/geolocation": "^4.7.0",
        "@ionic-native/onesignal": "^4.5.2",
        "@ionic-native/splash-screen": "4.4.0",
        "@ionic-native/status-bar": "4.4.0",
        "@ionic-native/twitter-connect": "^4.5.2",
        "@ionic/storage": "2.1.3",
        "angularfire2": "^5.0.0-rc.6",
        "cordova-android": "^7.0.0",
        "cordova-browser": "~5.0.3",
        "cordova-ios": "4.5.4",
        "cordova-plugin-camera": "^2.4.1",
        "cordova-plugin-compat": "^1.2.0",
        "cordova-plugin-device": "^1.1.7",
        "cordova-plugin-file": "^6.0.1",
        "cordova-plugin-filechooser": "^1.0.1",
        "cordova-plugin-filepath": "^1.3.0",
        "cordova-plugin-geolocation": "^4.0.1",
        "cordova-plugin-inappbrowser": "^2.0.2",
        "cordova-plugin-ionic-webview": "^1.2.0",
        "cordova-plugin-splashscreen": "^4.1.0",
        "cordova-plugin-statusbar": "^2.4.2",
        "cordova-plugin-whitelist": "^1.3.3",
        "firebase": "^4.12.1",
        "ionic-angular": "3.9.2",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "jssha": "^1.6.2",
        "moment": "^2.20.1",
        "onesignal-cordova-plugin": "^2.2.5",
        "rxjs": "5.5.2",
        "sw-toolbox": "3.6.0",
        "twitter-connect-plugin": "git+https://github.com/chroa/twitter-connect-plugin.git",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@angular/cli": "^1.7.3",
        "@angular-devkit/build-optimizer": "^0.5.7",
        "@ionic/app-scripts": "^3.1.8",
        "@types/jssha": "0.0.29",
        "typescript": "^2.6.2"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-inappbrowser": {},
            "cordova-plugin-device": {},
            "cordova-plugin-ionic-webview": {},
            "cordova-plugin-splashscreen": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-filechooser": {},
            "cordova-plugin-camera": {
                "CAMERA_USAGE_DESCRIPTION": " ",
                "PHOTOLIBRARY_USAGE_DESCRIPTION": " "
            },
            "twitter-connect-plugin": {
                "FABRIC_KEY": "XXXXXXXXXX",
                "TWITTER_KEY": "YYYYYYYYY",
                "TWITTER_SECRET": "ZZZZZZZZZZZZZZZ"
            },
            "cordova-plugin-statusbar": {},
            "cordova-plugin-filepath": {},
            "cordova-plugin-file": {},
            "cordova-plugin-geolocation": {}
        },
        "platforms": [
            "ios",
            "browser",
            "android"
        ]
    },
    "main": "index.js",
    "license": "ISC"
}

Edit: I updated my npm as suggested by @Suraj Rao, and I have version 6.0.0 as the current version, then i tried building again and i got this new related error

2 Answers2

1

You can try these steps this might help you!

First of all try npm install And follow either one of the following approach...

  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

OR alternatively

Modify:

node_modules/.bin/ionic-app-scripts.cmd

By adding:

@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" %*
)

And then run ionic build android --prod

Source Click here!

Update:

I'm not sure exactly what's going wrong but i can understand there is huge file or memory usage which is exceeding the limit.

Try this,

node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192 --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192 --prod --aot

Hope this helps you!

RajeshKdev
  • 6,365
  • 6
  • 58
  • 80
  • Probably you just clear your cache of windows, Press `Windows + R` and clear the following folders `temp`, `%temp%`, `prefetch`, and `recent`. After clearing this Restart Your Machine. And Run your command prompt as admin to compile the build. – RajeshKdev Apr 25 '18 at 06:51
  • Please look in to my comment and Updated answer! – RajeshKdev Apr 25 '18 at 06:52
  • I am still not making any head way. Still stuck on this error – Green Onyeji Apr 25 '18 at 12:42
  • Did you try to build other apps? I think that your project produces some huge file content/code. Which is causing this issue. But i'm not exactly sure. Try to build other apps and see what happens... – RajeshKdev Apr 26 '18 at 06:49
1

I observed that some of the problems were dependency incompatibility (some dependencies needed a particular version to work), but most especially --prod in ionic cordova build syntax. This build option is a nightmare of sort. Mine stayed more than 7 hours without terminating. Without this option, it means you are building with angular compiler when you need AOT. After much browsing and reading I was able to build without --prod, but still using AOT via this command ionic cordova run android --aot true --environmen t prod --output-hashing all --sourcemaps false --extract-css true --named-chunks false --build-optimizer true check it here. Though not sure if its the right thing to do, but I got the result i wanted.