I am struggling with an issue where on running any angular app locally the node process linked to ng serve
is using well over 100% of my CPU core's.
My current environment is:
Angular CLI: 7.3.10 Node: 11.15.0 OS: darwin x64 (Mac OS X Catalina 10.15.4) Angular: 7.2.16
I have come across numerous posts and issues about this where the common solutions appear to be to install fsevents
for Mac OS issues.
Things I have tried:
node-gyp
to rebuild fsevents
after its installedfsevents
(2.1.3) as an older version is specified as an optional dependency with angular-cli (1.2.13)nvm
alsonpm rebuild
No matter what I try, I keep observing high cpu usage, I have seen it creep up too 300-400% at times.
This is really hampering my development and I am hoping someone may have some bright ideas I could try out.
Failing that, I am wondering if I should try uninstalling node
completely, getting rid of nvm
and starting from scratch.
In Angular development context; transpilation/compilation causes CPU spike. When this happens too frequent, your system is in trouble.
There are certain ways to relieve the pain a little;
ng serve --live-reload false
or ng serve --no-live-reload
etc. depending on your Angular CLI version
npm install fsevents
npm rebuild fsevents
npm serve
ng serve --poll [ms]
CPU management is tricky, there can be many reasons for this problem. These are only a few possibilities closely related to Angular development. I hope this answer provides some options to try to the ones having the same trouble.
Maybe you have similar setup for you hot/live reloading on Docker
such as ng serve --host 0.0.0.0 --poll 1
. The poll
value is problematic, change it on something larger, for example 2000
, such that ng serve --host 0.0.0.0 --poll 2000
.
Now, you'll loose (almost) real-time hot/live reloading, but you'll save your CPU/battery and having 2 seconds delay before your app will refresh the changed code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With