Fix “xcode-select: error active developer directory” on Mac
Some Mac command line users working with nodejs and npm may see an error message and command failure along the lines of “xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance”. This error message sometimes appears after updating MacOS, migrating Macs, or
If you experience this error message, you’ll likely be able to fix it rather simply.
Solution 1: Install Command Line Tools
The easiest solution is simply to install command line tools on the Mac, which can be done from the command line. You can also simply install the full Xcode suite from the Mac App Store if you’re inclined to do so.
- Launch the Terminal and enter the following command to initiate the installation of Command Line Tools
- Proceed with installation when prompted
That alone may fix the “xcode-select error xcodebuild requires Xcode” error message.
Solution 2: Switch Directory for Command Line Tools
Sometimes, if you installed Xcode and Command Line Tools separately, you may need to re-specify the directory that is in use for command line tools with the following command entered into the Terminal:
sudo xcode-select --switch /Library/Developer/CommandLineTools
Solution 3: Install Xcode and Change Location for Command Line Tools
Another approach involves the full Xcode package which you can download from Apple.
- Open Xcode on the Mac, then pull down the Xcode menu and choose Preferences
- Go to “Locations” and select the proper Command Line Tools
Solution 4: Install Xcode into /Applications, Switch Directory Accordingly
And finally, another solution that has worked for some users when the above approaches do not work, is to install Xcode from the Mac App Store into the /Applications/ directory on the Mac. After Xcode is installed on the Mac, open the Terminal and enter the following path:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Which of these tricks worked to fix the “xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance” error message for you on your Mac? Did you find another solution? Let us know in the comments.