JavaScript heap out of memory issue

Hi guys,

I’m facing with this issue of “JavaScript heap out of memory” when I tried to deploy or up service with ‘serverless offiline’ command.

I’m using nestjs - a node framework - and building the project for node 10x.

I found some fixes like

  1. type " node --max-old-space-size=1024 index.js" on terminal
  2. use this package https://www.npmjs.com/package/increase-memory-limit
  3. append on script tag in package.json some like "“scripts”: {
    “webpacker”: “node --max_old_space_size=4096”
    not of theses works.

any clue?

On my terminal I got this below.
-----------------terminal---------------------
"PS D:\m1_workspace\dw-api> serverless offline
Serverless: Compiling with Typescript…
Serverless: Using local tsconfig.json

<— Last few GCs —>
al[21864:000001EF81231660] 20688 ms: Mark-sweep 1394.2 (1429.4) -> 1392.3 (1429.9) MB, 977.1 / 0.0 ms (+ 0.0 ms in 62 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 987 ms) (average mu = 0.074, current mu = 0.010) all[21864:000001EF81231660] 21557 ms: Mark-sweep 1392.3 (1429.9) -> 1392.2 (1427.9) MB, 868.1 / 0.0 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 868 ms) (average mu = 0.037, current mu = 0.001) allo

<— JS stacktrace —>

==== JS stack trace =========================================

Security context: 0x002e2c61e6e9
0: builtin exit frame: splice(this=0x03a8c4a97e89 <JSArray[8]>,0x0237e40868f9 ,0,8,0x03a8c4a97e89 <JSArray[8]>)

1: getUnionType(aka getUnionType) [00000057B5C33821] [D:\m1_workspace\dw-api\node_modules\@hewmen\serverless-plugin-typescript\node_modules\typescript\lib\typescript.js:~34245] [pc=000003F28C0363E9](this=0x007f886026f1 <undefined>,types=0x010...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory"