'How to cpulimit the `npm install` process?

Whenever I run the npm install command to install dependencies, CPU usage is getting too high, so I get a CPU alarm from my companies' infra. I want to reduce CPU usage even if I compromise on memory or speed. Is there any way to reduce CPU usage of npm install process?

I tried to use cpulimit, but it doesn't seem to work. I tried cpulimit -l 50 -- 'yarn --production', but CPU usage is still high when I see it in htop or top.

ps. I'm using AWS ElasticBeanstalk AMI 2 (5.5.1) with Node.js 16.14.0, npm 8.3.1



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source