Encountering a heap out of memory error in Github Action during 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.
Showcasing the 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
A possible solution:
env:
NODE_OPTIONS: "--max-old-space-size=4096"
Attempted to implement the solution but unsure if I need to add a "-" before "env" and its exact placement. Tried adding it under "run: npm run build --if-present working-directory: client" without success.