How to fix gyp: No Xcode or CLT version detected

xcode-select -print-path
/Library/Developer/CommandLineTools
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Update Nov 7, 2020, 5:33 PM:

With latest release of Xcode 12. This method no longer worked for macOS Catalina (10.15.7) and Big Sur. You should download it manually from Apple.