This error happens when the command line tools on MacOS are not installed correctly. Do the following to fix this problem:
- Test if the command line tools are working. Run:
curl -sL https://raw.githubusercontent.com/nodejs/node-gyp/main/macOS_Catalina_acid_test.sh | bash
- If the above retruns something like "Command Line Tools not found" then run the following:
sudo rm -rf $(xcode-select --print-path) xcode-select --install
- Click on "Install" in the prompt
- Agree to the terms and conditions
- Wait for installation to finish
- Test again if the command line tools are working. It should be fixed now.
If you still have issues then see this article by node-gyp.