Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I allocate more memory to node.js when running ng build? (Mac)

I have started to experience node crashes during ng build --prod, due to increasing memory requirements of my angular-cli app. I have seen solutions like this:

node --max_old_space_size=4096 myAwesomeServer.js

but how could that be applied to ng commands (esp. ng bundle)?

like image 845
user776686 Avatar asked Sep 08 '17 11:09

user776686


1 Answers

You allowed to setup node command line options through environment variable:

NODE_OPTIONS=--max-old-space-size=4096 ng bundle

https://nodejs.org/api/cli.html#cli_node_options_options

also you allowed to run ng like

node --max-old-space-size=2048 $(which ng) bundle # not tested by myself
like image 93
Akzhan Abdulin Avatar answered Sep 22 '22 10:09

Akzhan Abdulin