Home > Software design >  Error while setting-up Ionic environment in Ubuntu 20 ec2 instance
Error while setting-up Ionic environment in Ubuntu 20 ec2 instance

Time:02-22

I am trying to generate the Android and IOS platform folders on the ubuntu server, so that I can transfer the same to a machine that is capable of building a .apk and .ipa for the same. I was successful in doing this with Ionic CLI 6.18.1, @ionic/agular 5.9.3, cordova CLI: 10.0.0, and node 14.18.1, but had a lot of issues when upgrading the project with Ionic CLI 6.18.1, @ionic/agular 6.0.8, cordova CLI: 11.0.0 and node 16.14.0.

I would like to get some details on why this is happening and some document/video that I can refer to solve the same.

I have added the detailed error at the bottom

The error that I am constantly getting, only in ec2 instances are:

  1. FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory [e1]
  2. Error at new SubprocessError [e2]

The solution that I have tried:

To solve FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

  1. set NODE_OPTIONS=--max_old_space_size=8192

  2. changed package.json

    "scripts": { "ng-high-memory": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --configuration=prod", }

    npm run ng-high-memory

Detailed error:

[e1] FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

<--- Last few GCs --->

[10229:0x5132ba0]    64697 ms: Scavenge 479.8 (500.1) -> 479.5 (500.1) MB, 3.4 / 0.0 ms  (average mu = 0.445, current mu = 0.476) allocation failure
[10229:0x5132ba0]    64721 ms: Scavenge 480.2 (500.1) -> 479.8 (504.1) MB, 22.5 / 0.0 ms  (average mu = 0.445, current mu = 0.476) allocation failure


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb09980 node::Abort() [ng run app:ionic-cordova-build --platform=browser]
 2: 0xa1c235 node::FatalError(char const, char const) [ng run app:ionic-cordova-build --platform=browser]
 3: 0xcf77be v8::Utils::ReportOOMFailure(v8::internal::Isolate, char const, bool) [ng run app:ionic-cordova-build --platform=browser]
 4: 0xcf7b37 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, bool) [ng run app:ionic-cordova-build --platform=browser]
 5: 0xeaf3d5  [ng run app:ionic-cordova-build --platform=browser]
 6: 0xebf09d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng run app:ionic-cordova-build --platform=browser]
 7: 0xec1d9e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [ng run app:ionic-cordova-build --platform=browser]
 8: 0xe83257 v8::internal::Factory::New(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType) [ng run app:ionic-cordova-build --platform=browser]
 9: 0xe93141 v8::internal::Factory::NewProperSubString(v8::internal::Handle<v8::internal::String>, int, int) [ng run app:ionic-cordova-build --platform=browser]
10: 0x12123a5 v8::internal::Runtime_StringSplit(int, unsigned long, v8::internal::Isolate) [ng run app:ionic-cordova-build --platform=browser]
11: 0x15f0a99  [ng run app:ionic-cordova-build --platform=browser]
Error

[e2] Error at new SubprocessError

at new SubprocessError
(/home/ec2-user/.nvm/versions/node/v16.14.0/lib/node_modules/@ionic/cli/node_modules/@ionic/utils-subprocess/dist/index.js:41:23)
at ChildProcess.<anonymous>
(/home/ec2-user/.nvm/versions/node/v16.14.0/lib/node_modules/@ionic/cli/node_modules/@ionic/utils-subprocess/dist/index.js:125:27)
at ChildProcess.emit (node:events:520:28)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
[ec2-user@ip-10-100-0-156 ionic]$

CodePudding user response:

I was able to solve the issue by upgrading the RAM from 1 to 2 GB (t2.micro - t2.small).

We came to this conclusion by running series of test in VM(Virtual Machine) by replicating the same environment.

Thanks.

  • Related