This is a very common error that many developers encounter these days. I tried different ways to solve it using various approaches. In this case, you can’t downgrade your code version because it is not compatible with the latest macOS. I tried removing node_modules and reinstalling them, installing pods, restarting the laptop, and upgrading all package managers like CocoaPods. I also created new projects and tried everything, but nothing worked.
To resolve this, simply remove any spaces in your project folder and the parent folder. Spaces in folder names can cause issues with various tools and scripts, leading to errors. Renaming these folders to remove spaces can help avoid such problems.