Mostly in a Macbook m series chip you are going to face this problems if you encounter this error that mean you need to increase your stack size
for that type 'ulimit -n' on you bash or zsh terminal
and then type 'ulimit -n 4096' for temporary increase the limit.
or To make it permanent, you can add the following line to your ~/.bash_profile or ~/.zshrc.
Make sure to restart your system
If still the problem if there delete node module and reinstall it.