If you have recently updated your macOS, 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.

To reinstall the XCode command line in macOS, run the following commands step by step.

Step 1: Find the XCode installation location

To get the XCode installation path, 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 this message to reinstall the XCode command-line tools.

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 XCode command-line tools, then run the following command in the terminal.

xcode-select --install

xcode install

Click on the install button 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 installation is done. Try to do the npm install again and you will not receive the no Xcode or CLT version detected macOS error.