-2

Working on a react project. when I try to run npm run build it shows java script heap out of memory error.

Error details

I tried to find memory leak but no memory leak found but it is a single page application so when page is renders at the time compiled code only increase shallow size.

The same project and same code build successfully by my colleague laptop.

"build": "react-scripts --max_old_space_size=4096 bild" in my laptop I used above command at package.json file build works correctly.

Now my dought is maybe my project have a any memory leak above the command will it work or not?

Above command will it work at gitlab or not?

1
  • Please post the error text as a text. Commented Oct 8, 2023 at 13:45

1 Answer 1

0

Your laptop, the laptop of your colleague and GitLab can have different NodeJS versions and different size of RAM. The different NodeJS versions have different default limit of the memory heap. Since you are explicitly setting the limit for the memory heap, I would say that the application need bigger memory heap or the RAM on your laptop is not so much.

Regarding the official documentation

On a machine with 2 GiB of memory, consider setting this to 1536 (1.5 GiB) to leave some memory for other uses and avoid swapping.

I would recommend to use the latest LTS version of NodeJS, to have enough RAM on the machine and to not explicitly set the memory size limit.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.