Why node -gyp rebuild does not work on Mac OSX El Capitan

I recently bought a mac that uses Mac OSX El Capitan v10.11.4. Node is installed with homebrew and I am using node v6.2.2 and npm v3.9.5. I get an error with bcrypt during npm install , which I suppose comes 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 complete withdrawal of errors after I ran npm install :

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

Not sure what will go wrong. I come from linux land and, as a rule, I am afraid not to install from the source code, maybe this is the reason for these problems? In any case, any advice will be appreciated. I also saw this error occurring for others, but none of their solutions seemed to work (when I type xcode-select --print-path , I get /Applications/Xcode.app/Contents/Developer )

+14
source share
5 answers

This one bit me too. There were several different solutions, only one of them worked for me.

First, make sure you have the Xcode command line tools installed, as the npm page says.

1) The simplest solution, which, of course, did not work (although it looks like it was for some people), you just need to delete the ~/.node-gyp . So you can also take this snapshot as well as remove your node_modules dir and do another npm install .

2) Try removing node -gyp and reinstalling:

 sudo npm uninstall node-gyp -g npm uninstall node-gyp npm install 

3). But what trick was the solution is given in the node -gyp problem on github , where you need to install another version of node and make your npm that way. This is simpler than it sounds, but it's pretty rude:

 sudo npm cache clean -f sudo npm install -gn sudo n 4.4.5 sudo npm install npm -g sudo npm uninstall node-gyp -g 

Then try running npm install.

Hope this helps!

+14
source

If the node_modules cache was created using the latest version of Node, you may need to delete the cache, return it, and then reinstall the packages:

 rm -rf node_modules nvm use 6 npm install 
+1
source

If you are using virtualenv for your python, you need to deactivate it or specify npm to use the python 2 native installation for the gyp node to work.


EDIT:

There was another meeting with the same error a few days ago. This time there was no guilt around the hype node. Obviously, the module I installed depends on the very old version of node-gyp (v1), regardless of the version of the system (v3.8) that my version of the node (v10) no longer supports. Since I no longer need this module, I deleted it. Alternatively, you can upgrade / downgrade / replace a failed module or upgrade / downgrade your node. In the case of OP, the intruder module was bcrypt@0.8.5.

+1
source

After I tried many solutions, the removal of nodes, n, npm and nvm worked for me. Reinstalling nvm and installing the node with it. I followed this answer:

How to completely remove Node.js and reinstall from the very beginning (Mac OS X)

It hurts and takes a long time, but it works.

0
source

if you want to upgrade Node to 10 or higher, you should find the deprecated dependencies with Node 10 in package.json and upgrade these packages to a newer stable version, and then build (npm / yarn install).

0
source

All Articles