node.jsangular-universalnrwlnomachine-nx

Angular Universal: Node/Javascript Memory heap still failing after upping max_old_space_size


For some reason, even after changing max_old_space_size to 8192 I am still getting the error that:

FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
"start": "export NODE_OPTIONS=--max_old_space_size=8192 && nx run zeta-frontend:serve-ssr",

This is what my command looks like ^

Notes:

  1. Using nrwl nx might have to do with. Not sure. However, it is erroring out at around the default of 1.6gb.
  2. Left a sister github issue for this one: https://github.com/nrwl/nx/issues/14054

Solution

  • UPDATE:

    Was able to solve via the following:

    1.

    "ng": "node --max-old-space-size=8192 ./node_modules/.bin/ng",
    "nx": "node --max-old-space-size=8192 ./node_modules/.bin/nx",
    "start:serve": "npm run nx -- run zeta-frontend:serve",
    
    1. Being that angular universal makes a large initial bundle on serve, it would cause the development bundle to fail silently unless budget was updated. By doing the following:
    "budgets": [
      {
        "type": "initial",
        "maximumWarning": "20mb",
        "maximumError": "40mb"
      },
     ...
    ]
    

    It allowed the angular universal build to pass.

    ^ feel free to try above if have the same problem