Ionic, 200+ pages, build production .out of memory error

I just got update of ionic-cli and angular core. Now this command (ionic cordova run android --prod) is running perfectly.

Please update your ionic-cli. You will get a warning to install updates when you will use ionic cordova run android.

yes ,it seem’s ok now ,it work fine to me too :yum::yum::yum:
thx @Sujan12,thx @aditya_1027

1.modify the warnning
2.update ionic cli to newest…

Hello @sky_zt , I updated my ionic cli but that does not worked - same problem. How do I modify the warning…?

1 Like

Create a new topic and include all the relevant information that I asked @sky_zt about here in these posts. Thanks.,

How did you modify the warning ?

Hello,

you ask to an old post. Maybe it is better, if you describe your problem with all necesarry things.

If you have the heap out of memory problem, then search on your computer (win) for ionic.cmd and replace (after backup) content with

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe" --max_old_space_size=4096 "%~dp0\node_modules\ionic\bin\ionic" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node --max_old_space_size=4096 "%~dp0\node_modules\ionic\bin\ionic" %*
)

For more infos or other OSes look here https://github.com/ionic-team/ionic-cli/issues/1453

Best regards, anna-liebt

That did not work, This did work

ionic cordova run android --aot true --environment prod --output-hashing all --sourcemaps false --extract-css true --named-chunks false --build-optimizer true

Hello,
this is not working for me. It produce a very long error list. I look a little bit around and found same discussion that also used specifiy flags, webpacks configs, etc… I tried some but none of them was working for me. Interesting was that some people reported, that they have reduce there build time drastically. The huge build time is really terrible time waster. So I am looking forward for a quicker solution for the heap out of memory problem.

Best regards, anna-liebt

Try this in package.json > scripts> build

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 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build --prod --aot

I’m using the cross-env to solve it.

{
  ...
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" ionic-app-scripts build --prod --release",
    ..