DEV Community

Cover image for 🏇 A simple tip to improve angulars compilation speed

🏇 A simple tip to improve angulars compilation speed

Marcel Cremer on May 17, 2019

Do you have a large angular application that takes too long to compile / serve / compile tests? This little thing helped me: Increasing t...
Collapse
 
t0f3rchr15 profile image
Christopher Carter

I believe you can use an .npmrc file at the project level and avoid altering your scripts altogether

node-options=--max-old-space-size={{size in MB}}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
bennettbackward profile image
Bennett Hardwick

For those with computers that are packing a lot of ram, you can allow this option globally for all node applications by adding the following to your shell config:

export NODE_OPTIONS="--max_old_space_size=8096"
Collapse
 
yamakasy profile image
Iker A Saber • Edited

If you want to check how much RAM is node allocating currently, you can use this:

node -e 'console.log(v8.getHeapStatistics())'
Enter fullscreen mode Exit fullscreen mode
Collapse
 
marcel_cremer profile image
Marcel Cremer

Thank you for your input about npmrc and export guys :)

I personally don't like the export solution as it's global, but its definetly worth mentioning (for ppl who want to alter the size always).

About the .npmrc file: I honestly didn't know that it's also possible to have this on project level (only in the home folder). I'll give this one a try too.

Collapse
 
cbolourchi profile image
cbolourchi

Does anyone know how I would get this to work in Gitlab CI?

I've tried using NODE_OPTIONS in my gitlab-ci.yml and added node-options=--max-old-space-size=2048 to the .npmrc file in the project root, but whenever I do npm run-script build-prod it just reverts back to 80000 and my build never finishes on my machine. I'm using my own gitlab-runner.

I'm really at a loss.

Any help would be appreciated. Thanks.

Collapse
 
kienngo profile image
ken

Hmm, will definitely check this out!
Thanks for the article <3

Collapse
 
steveblue profile image
Stephen Belovarich

So simple yet so effective. I like it!

Collapse
 
ciel profile image
Ciel

It definitely seems good, but something about this has me expecting my house to explode.

Collapse
 
siddharthshyniben profile image
Siddharth

Man you have a huge RAM. I'm stilling playing with 6GB Ram 😅

Collapse
 
dfloresgonz profile image
Diego RFG • Edited

I have 32GB RAM can't I increase the max_old_space_size? (more than 8096)