Why is node-gyp rebuild failing on Mac OSX El Capitan
Solution 1
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/
Solution 2
This one just bit me, too. There were a couple of different solutions, only one of which worked for me.
First, make sure you have the XCode command line tools installed, as they say on their npm page.
1) The simplest solution, which of course didn't work (though it looks like it did for some people), is to just delete the ~/.node-gyp
directory. So might as well give that a shot, as well as deleting your node_modules
dir and doing another npm install
.
2) Try uninstalling node-gyp and re-installing:
sudo npm uninstall node-gyp -g
npm uninstall node-gyp
npm install
3) But what did the trick was a solution given in a node-gyp issue on github, where you have to install another version of node and do your npm install that way. It's easier than it sounds, but it's pretty gross:
sudo npm cache clean -f
sudo npm install -g n
sudo n 4.4.5
sudo npm install npm -g
sudo npm uninstall node-gyp -g
Then try running npm install.
Hope that helps!
Solution 3
I have a simple solution. If the xcode-sellect is installed try running
sudo xcode-select --reset
Solution 4
If the node_modules
cache was built with a recent version of Node, you may need to remove the cache, revert back and then reinstall the packages:
rm -rf node_modules
nvm use 6
npm install
Solution 5
For anyone who tried reinstalling Xcode tools yet the same issue persists.
You will have to go following file:
~/.node-gyp/<your_node_version_here>/include/node/common.gypi
Note: Make sure to change <you_node_version_here> to your node version like:
~/.node-gyp/16.13.1/include/node/common.gypi You can find node version using node -v
Inside search for key MACOSX_DEPLOYMENT_TARGET and change it's value to your current os version like mine is 11.3.1 and you will be good to go. You can find version in
about this mac
option in drop down of mac logo
roonie
Updated on July 09, 2022Comments
-
roonie almost 2 years
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 anode-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
)-
robertklep almost 8 yearsI regularly see issue appearing that have to do with Homebrew installations of Node that are solved by using the official installer. Might be worth a try.
-
-
jmansurf over 4 yearsYou totally rock.. the only thing that came close to working! Thanks
-
metakungfu about 4 yearsJust updated to 10.15.4 & had the same issue - I googled & found again my own answer which worked... awesome.
-
thomallen over 3 yearsI'm having issues on Big Sur and this fix does not seem to work. Any issues for you? Maybe I need to update python or something cause I'm seeing it reference python in the error trace?
-
metakungfu over 3 yearsI'm also on BigSur - I had the same issue & the same fix worked. Though it came back a couple times when I was updating to the latest beta release. You should try again. I'm not sure if python is related.
-
thomallen over 3 yearsYeah we had multiple devs deal with this issue this week so we just removed bcrypt from our project which was the only package using node-gyp.
-
Aashiq over 2 yearsWhy this answer is not the right one , this worked mostly