Search code examples
node.jsangularappveyor

Nodejs Appveyor build running out of memory


We're running builds on AppVeyor to build an AOT angular 2 application.

The build has started failing, giving the following:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

From what I can tell, you can use --max_old_space_size=xxxx where xxxx is the size you want to increase memory to. The default is 512. The problem is, I'm not sure where to add this flag. I've tried both dashes (what I found originall) and underscores. I've placed the flag as part of the ps build command definition, in the build scripts build configuration, and in the package.json scripts definitions to no avail.

I'm sure this just has to be put in the right spot, but I'm unclear as to where to add it. Any help would be appreciated.

Thanks


Solution

  • In appveyor.yml:

    init:
    - ps: Install-Product node 8
    - cmd: set NODE_OPTIONS=--max-old-space-size=1028
    

    This sets a node env var during init. Set it as high as you like.

    This reduced build times for us by about 80% as well. Incredible.