Why is node-gyp rebuild failing on Mac OSX El Capitan

roonie picture roonie · Jun 27, 2016 · Viewed 33.6k times · Source

I recently bought a mac, which uses Mac OSX El Capitan v10.11.4. Installed node with homebrew, and am using node v6.2.2 and npm v3.9.5. I'm getting an error with bcrypt during npm install, which I believe derives from a node-gyp rebuild error. I also recently downloaded xcode-select(version 2343) and xcode(7.3.1) (in that order).

Here is the full error output after i run npm install:

https://gist.github.com/varunjayaraman/5734af617d616437cd5b3456b20bc503

Not sure what's going wrong. I come from linux land and do tend to be wary of not installing from source myself, so maybe that is the cause of these issues? Anyway, any advice would be super appreciated. I also saw this error springing up for others, but none of their solutions seemed to work (when i type xcode-select --print-path, I get /Applications/Xcode.app/Contents/Developer)

Answer

metakungfu picture metakungfu · Nov 22, 2019

Anytime i upgrade OSX to newer version, I get the same issue. Here is how i solve it every time:

sudo rm -rf  /Library/Developer/CommandLineTools
xcode-select --install

That's it. Now next time you do npm install or yarn it'll work.

PS: Sometimes you won't be able to install the command line tool through Xcode-select, for example if you are on beta. In that case, you should be able to install it manually from here: https://developer.apple.com/download/more/