No Xcode or CLT version detected!

bob.ts - Jun 11 '20 - - Dev Community

These are notes for myself on an issue I had recently and the resolution that worked for me ...

The Issue

I recently updated my Mac OS. What I immediately noticed any time I ran either yarn install or npm install, I got this new error:

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
Enter fullscreen mode Exit fullscreen mode

Keep in mind that this wasn't event close to the complete list of errors. The messages ran on and on. The funny thing is I do have these command line tools installed.

The result of xcode-select --install starts the re-installation process, but if you get the message below then you (as I did) already have the command line tools installed.

Xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Enter fullscreen mode Exit fullscreen mode

Solution

Reinstall the command-line tools by removing the previously installed version, then reinstall them.

Get The Location

Get the location of the installed command-line tools by running the command below:

xcode-select --print-path
Enter fullscreen mode Exit fullscreen mode

Which gives the results from the command above (here's what I got) ...

/Library/Developer/CommandLineTools
Enter fullscreen mode Exit fullscreen mode

Remove The Tools

Knowing the path to the currently installed command-line tools from the previous step, go ahead and remove them from the system. For the next set of commands, you will need sudo privileges to run successfully.

sudo rm -r -f /Library/Developer/CommandLineTools
Enter fullscreen mode Exit fullscreen mode

Provide the root password to remove the command line tools, when prompted.

Reinstall The Tools

Prompt to reinstall command line developer tools

Click on install and follow the rest of the instructions to reinstall command line developer tools.

If for some reasons, you do not get the prompt right after uninstalling your previous command line developer tools, no need to panic. Run the following command to get the prompt.

xcode-select --install
Enter fullscreen mode Exit fullscreen mode

Prompt after running Xcode-select -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. The installation process should proceed immediately after a successful download.

Conclusion

With the reinstallation of the command line developer tools the gyp: No Xcode or CLT version detected! error message should disappear when any yarn or npm command is run from the command line.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .