Node-gyp compilation error: Cannot detect Xcode or Command Line Tools during package installation

I’m facing an issue when trying to run npm install. The error shows that it cannot find Xcode or Command Line Tools. This seems to have started occurring after I updated my macOS to Catalina.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1

I am using Node version 8.8.0 and npm version 6.11.3, and this problem happens in both my VSCode terminal and iTerm. It appears that my system can’t locate the command line tools necessary for compiling native modules.

Has anyone else faced this problem after upgrading macOS? What steps should I take to fix this compilation error?

I encountered a similar issue post-Catalina upgrade. It appears that updating macOS often disrupts the Command Line Tools installation. To resolve this, execute sudo xcode-select --install in the terminal; this will guide you through the reinstallation process. If that doesn’t resolve the issue, you might want to try sudo xcode-select --reset first, followed by attempting the installation again. Once you’ve gone through the steps, verify the installation with xcode-select -p, which should display a path like /Library/Developer/CommandLineTools. This resolved my node-gyp compilation errors.

Had the exact same issue after upgrading to Catalina. macOS upgrades mess up developer tool configs all the time. Before you reinstall Command Line Tools, run xcode-select --print-path to see if they’re actually there. If it shows a path but you’re still getting the gyp error, your tools are probably corrupted, not missing. I had to nuke the existing install first with sudo rm -rf /Library/Developer/CommandLineTools then do a clean install with sudo xcode-select --install. Also, Node 8.8.0 is pretty old and might not play nice with newer macOS versions. You should upgrade to a recent LTS version once you get the build tools working.

weird, I had this exact same thing happen. The issue was actually my npm cache being corrupted. Try running npm cache clean --force before messing with Xcode stuff. sometimes the gyp error’s misleading and it’s not really about command line tools. worth a shot before you nuke everything and reinstall.