how to increase memory heap in nest.js application ? how to use --max-old-space-size in cli?

Viewed 6041

I am working on node.js project with nest.js framework and I had the error "JavaScript heap out of memory" my question is how to allocate more memory to my app?. Also I found some people say that I should use [--max-old-space-size] to allocate memory so I tried to add this option to package.json scripts to have "start" : "nest start --max-old-space-size=4096" but it didn't work

2 Answers

Nest passes some, but not all, flags through to node. This is one of the flags that it does not. Instead, you can use node dist/main --max-old-space-size=4096 and get the server to start that way.

Jay McDoniel was right about this, however the argument is in the wrong order, you must pass like this node --max-old-space-size=4096 dist/main

Make sure you do a npm run build if you haven't before.

Related