Search code examples
node.jsangularprofilingv8

Starting node with v8 profiler enabled from ng start


When starting my application in development mode I see 50% of the CPU is used by node executable. I wanted to know if this is something related with my code or something related with how node works.

I found a nice response to a similar question here: how to debug node.js causing 100% cpu usage?

But I cannot follow the indicated steps because I'm developing using angular, and angular is started by running ng serve.

The documentation of ng serve is here: https://angular.io/cli/serve but I can't see anything to send additional parameters to node. Even more, if I try to do ng serve --prof an error is generated.

What else can I do in order to profile the execution of node.js?

Thanks for your time


Solution

  • Use the path of the ng script as parameter for the node binary like this:

    node --prof ./node_modules/@angular/cli/bin/ng serve