Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Actions - Reached heap limit Allocation failed

Github Action gives my this error for the last "run: npm run build"

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
Error: Process completed with exit code 1.

My workflow file

name: Node.js CI

on:
  push:
    branches: ['master']

jobs:
  build:
    runs-on: self-hosted

    strategy:
      matrix:
        node-version: [16.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
      - run: npm i
      - run: npm i
        working-directory: client
      - run: npm run build --if-present
        working-directory: client

I think this is the solution

env:
   NODE_OPTIONS: "--max-old-space-size=4096"

But it didn't work yet im not sure i've to add "-" before the env and the exact position of it... I did it under "run: npm run build --if-present working-directory: client" but didn't work.

like image 827
zuZuu Avatar asked Dec 13 '25 10:12

zuZuu


1 Answers

According to this response to a similar issue:

run

jobs:
  make-love:
    steps:
      - name: "Just do it"
        run: |
        export NODE_OPTIONS="--max_old_space_size=4096"
        npm start

env

jobs:
  make-love:
    steps:
      - name: "Nothing is impossible"
        env:
          NODE_OPTIONS: "--max_old_space_size=4096"
        run: npm start
like image 85
Lounge9 Avatar answered Dec 15 '25 08:12

Lounge9