FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of memory while running typescript node project Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of memory while running typescript node project without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have launched a t2.micro server on aws and while running our application on server with simply “sudo npm start” i am getting :

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

tried many solution like upgraded node version and set NODE_OPTIONS=–max-old-space-size=1024 but it didn’t work for me so can anyone please help me out to resove this issue ?

start script: tsc && node dist/index.js

Thanks

Answer

You’re just running out of memory to build your project on a t2.micro. Typescript builds are memory-heavy.

You could

  • set up swap memory on the machine (see e.g. https://wiki.archlinux.org/index.php/swap#Manually) (which will not be very performant)
  • or better yet, build your project (tsc) on a beefier machine and only run the compiled Javascript (node dist/index.js) on the micro machine.
We are here to answer your question about FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of memory while running typescript node project - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji