Mac: Xcode update breaks NPM installs… every time!

Now what’s up with that? You are humming along nicely and then suddenly your NPM/Yarn installs are breaking.

Yarn: No Xcode or CLT version detected!

Really? Why?

Inspecting the error message, the problem appears to be with node-gyp, the part where C++ code is compiled for the module being installed.

It might not fail completely (i.e., a warning) and fallback to using JavaScript taking a performance hit.

For some reason, the issue appears to be related to a messed up Xcode environment due to the update and happens every time Xcode gets bumped up.

Fix ain’t pretty; multiple variants found across the web. Here is what worked for me (Catalina 10.15, Xcode 11.3):

sudo rm -rf $(xcode-select -print-path)
xcode-select --install
sudo npm install -g node-gyp

Not sure why Apple refuses to fix this, in spite of being a common problem. Developers are expected to do it the hard way, I suppose!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.