Ionic error during build (Debug failure)


#1

When I try to build my project with either ionic cordova run android or ionic serve -c, I run into this error, which does not really help me to pinpoint the problem. I was not able to find any information with this:

D:\APPS\*****\*****>ionic serve -c --verbose
[DEBUG] Reason for not using local CLI: LOCAL_CLI_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'D:\\APPS\\*****\\******', local: false, binPath:
    'C:\\Users\\*****\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath:
    'C:\\Users\\*****\\AppData\\Roaming\\npm\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] New daemon pid: 12084
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --consolelogs
--nobrowser - Ctrl+C to cancel
[20:03:59]  watch started ...
[20:03:59]  build dev started ...
[20:03:59]  clean started ...
[20:03:59]  clean finished in 3 ms
[20:03:59]  copy started ...
[20:04:00]  deeplinks started ...
Error: Debug Failure.
at new BuildError (D:\APPS\*****\*****\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)
at D:\APPS\*****\*****\node_modules\@ionic\app-scripts\dist\deep-linking.js:57:21
at <anonymous>
[DEBUG] Error: Debug Failure.
        at new BuildError (D:\APPS\*****\*****\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)
        at D:\APPS\*****\*****\node_modules\@ionic\app-scripts\dist\deep-linking.js:57:21
        at <anonymous>
[20:04:00]  copy finished in 561 m

I tried updating the module app-scripts with npm install @ionic/app-scripts, but the same error happens again. I’m out of ideas… anyone knows how to tackle this one?


#2

What is your ionic info output?
Does it work for a new app created with ionic start?


#3

‘ionic info’ output:

cli packages: (C:\Users\******\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : not installed

local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : ZZZ_android 6.4.0 android 6.4.0 browser 5.0.3
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.9.4
    npm               : 5.7.1
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : D:\AndroidDevelopmentSDK

Misc:

    backend : pro

The error only occurs in my ongoing project. I can successfully create a new one and build it.


#4

Additional info:
After a ‘npm update’ , the output changed to this:

D:\APPS\******\*********>ionic cordova run android
Running app-scripts build: --platform android --target cordova
[20:01:41]  build dev started ...
[20:01:41]  clean started ...
[20:01:41]  clean finished in 5 ms
[20:01:41]  copy started ...
[20:01:41]  deeplinks started ...
[20:01:42]  deeplinks finished in 266 ms
[20:01:42]  transpile started ...

<--- Last few GCs --->

[4776:00000205831E9400]   152297 ms: Mark-sweep 1399.6 (1476.3) -> 1399.6 (1476.3) MB, 122.4 / 0.0 ms  allocation failure GC in old space requested
[4776:00000205831E9400]   152446 ms: Mark-sweep 1399.6 (1476.3) -> 1399.5 (1440.8) MB, 149.1 / 0.0 ms  last resort GC in old space requested
[4776:00000205831E9400]   152579 ms: Mark-sweep 1399.5 (1440.8) -> 1399.5 (1440.8) MB, 132.8 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

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

Security context: 000002CACCC25EE1 <JSObject>
    2: replace(this=00000250A5E47031 <Very long string[286108]>,00000250A5E47059 <JSRegExp <String[3]: \\r>>,000003FE66312401 <String[1]\: \n>)
    3: splitLineBreaks [D:\APPS\*******\**********\node_modules\@ionic\app-scripts\dist\util\helpers.js:~79] [pc=000001812A57672D](this=0000027D2FD44E91 <Object map = 0000000A07CB6E99>,sourceText=00000250A5E47031 <Very long string[286108]>)
    5: ...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node_module_register
 2: v8::internal::FatalProcessOutOfMemory
 3: v8::internal::FatalProcessOutOfMemory
 4: v8::internal::Factory::NewRawTwoByteString
 5: v8::internal::Smi::SmiPrint
 6: v8::internal::AllocationSpaceName
 7: v8::internal::ParserBase<v8::internal::Parser>::MarkLoopVariableAsAssigned
 8: v8::internal::ParserBase<v8::internal::Parser>::MarkLoopVariableAsAssigned
 9: 000001812A3047A1

#5

ionic serve and ionic cordova run are two very different commands.


#6

Yes, I’m aware of that, I actually only meant to post it because the output seems to tell more than the output from the 1st message. Would you have any idea what I can do about this?


#7

So this has started happening to me too. I cannot get anything to build now, at all. Code that built yesterday against the same package.json entries now does not. I have tried leaving the build running for well over an hour, and watched node consume ~12GB of RAM, drop to 1GB, back up to 12GB, over and over and never ever finish. I cannot build using Ionic Pro. I cannot build locally.

SOMETHING in a dependency got updated using a carat semver spec, and it has broken AOT, Typescript, and Webpack. I don’t think it is ionic-app-scripts that is the culprit; I think it is some dependency somewhere.

I really don’t know what to do.

EDIT: Forgot to add, this is trying to do a --prod build: ionic-app-scripts build --prod --release. I am on latest app scripts and ionic-angular, Angular 5.2.6, RxJS 5.5.5, Zone.js 0.8.18. This is for Ionic 3.


#8

For anyone else who might be running into an out of memory error yesterday or today (April 21, 2018), if you are using Firebase, they just published a version that has a massive memory leak. Read all about it here:

Reverting to 4.12.1 resolves the issue.


#9

I started to go through my project again and noticed that one HTML document and its .ts file were completely altered. Instead of the HTML / .ts code, both files had been replaced with HTML data from github (?!?). I have absolutely no clue how this has happened. When I put my project’s contents back in those files, I was able to run the build successfully. The memory usage never went above 1.5 GB during that.

How this happened is a complete mystery to me. I remember only pushing my code to github before I started to create a test build… I did not download or replace any files directly into my project folder.

Someone might have a better idea about this?

Anyway, I recommend doing the same, just in case you come across a similar error that points to “JavaScript heap out of memory”.