gyp: No Xcode or CLT version detected macOS

If you have recently updated your macOS, especially macOS Catalina or macOS Big Sur, you might be getting this error while doing a usual npm install.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error

The general solution to this problem is installing the XCode.

To install the XCode command line, you need to run the following command:

xcode-select --install

When you run this command, you might be getting the message that XCode is already installed. To fix this issue, we need to reinstall XCode in our MacOS. 

In this article, we will see three easy steps to reinstall XCode in MacOS in order to resolve the ‘gyp: No Xcode or CLT version detected!’ error. Let’s get started.

Also Read: Debugging “Make Failed with Exit Code 2” Error

Fixing GYP Error ‘No Xcode or CLT Version Detected’ 

Let us now see the step-by-step process to resolve the ‘No Xcode or CLT version detected’ GYP error.

Step 1: Find the XCode installation location

To get the installation path of XCode, run the following command:

xcode-select --print-path

The result of this command will be /Library/Developer/CommandLineTools. If it’s different then please make a note and copy the path.

Step 2: Delete the Existing XCode installation

Use the following command to delete the existing XCode installation:

sudo rm -r -f /Library/Developer/CommandLineTools

You might get the message to install command line tools for XCode as shown in the image given below.

git installation

Click on the Install button and follow the rest of the instructions.

Step 3: Installing XCode command line tools

If you don’t get the prompt to reinstall command line developer tools, then run the following command in the terminal:

xcode-select --install
xcode install

Click on Install and then agree to the license to proceed with the installation.

Depending on your internet speed it will take some time for the system to complete the download of the command line developer tools.

Once the command line tools installed, try to run either yarn install or npm install again and you will not receive the ‘No Xcode or CLT version detected!’ error.

Conclusion

If you are getting the error ‘gyp: No Xcode or CLT version detected!’ after a software update or updating your macOS, the problem might be solved easily by reinstalling the XCode command-line tools. This error can also happen due to a version mismatch. For this you first have to find the XCode installation location, then delete it using the command ‘sudo rm -r -f /Library/Developer/CommandLineTools’ and then again install it using the ‘xcode-select –install’ command. That’s all in this article, we hope this article helped you solve your problem.

Read More: Setting up Mac for Development/Coding

Reference

`npm install` fails on node-gyp rebuild with `gyp: No Xcode or CLT version detected!`– stack overflow

Pankaj Kumar
Pankaj Kumar
Articles: 208