Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)

like image 361
roonie Avatar asked Jun 27 '16 15:06

roonie


People also ask

How do I fix node-gyp error on Mac?

If the most complex node-gyp -related dependency you have in your project is something common like node-sass then this is usually the fix you need. Open the file, find the MACOSX_DEPLOYMENT_TARGET key value and replace it with your current Mac OS version ( 10.15. 3 for Catalina for example).

Why do I need node-gyp?

node-gyp is a tool that enables the compilation of native add-on modules for Node in multiple platforms. It has widespread use and is included as a dependency in many NPM packages. On most systems, this isn't an issue, and installing node-gyp with the rest of your packages works as expected.

What file does node-gyp read the build?

The binding.gyp file A binding.gyp file describes the configuration to build your module, in a JSON-like format. This file gets placed in the root of your package, alongside package.json .

What does node pre gyp do?

node-pre-gyp makes it easy to publish and install Node. js C++ addons from binaries. node-pre-gyp stands between npm and node-gyp and offers a cross-platform method of binary deployment.


1 Answers

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/

like image 174
metakungfu Avatar answered Oct 11 '22 18:10

metakungfu