Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

357
Visualizações
How to set max-old-space-size for typescript compiler (tsc)?

I have tsc job failing on gitlab ci with FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

The script I'm running is tsc -p test/tsconfig.json --noEmit

What I've tried so far is to increase max-old-space-size via:

  1. cross-env NODE_OPTIONS=--max-old-space-size=8192 yarn print:heapsize && tsc -p test/tsconfig.json --noEmit
  2. cross-env NODE_OPTIONS='--max-old-space-size=8192' yarn print:heapsize && tsc -p test/tsconfig.json --noEmit (just extra quotes around var)
  3. node --max-old-space-size=8192 ./node_modules/.bin/tsc -p test/tsconfig.json --noEmit

Options #1 and #2 doesn't work, and #3 works fine, but it doesn't sound okay to me to run the binary and pass param to the node cli

So my question is - how do I set max-old-spce-size for tsc via env variables or maybe there is another good way to do it?

yarn print:heapsize is the script I used to check current size - it shows 8gb for both #1 and #2 here it is:

"print:heapsize": "node -e \"console.log('🔥 Current heap size:', (require('v8').getHeapStatistics().total_available_size / 1024 / 1024 / 1024).toFixed(2), 'Gb')\""

and here's the output enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The first two options fail because the environment variable NODE_OPTIONS=--max-old-space-size=8192 applies only to the first command (yarn print:heapsize) that is before &&.

If you remove yarn print:heapsize && the environment will apply to the compilation command as expected:

cross-env NODE_OPTIONS=--max-old-space-size=8192 tsc -p test/tsconfig.json --noEmit

about 4 years ago · Juan Pablo Isaza Relatório

0

tsc is deprecated but you can use ts-node with --max-old-space-size in NODE_OPTIONS

Add this options in your package.json

{
  "scripts": {
    "start": "NODE_OPTIONS='--max-old-space-size=8192' ts-node index.ts"
   }
}  
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda