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
)
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!
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
If you are using virtualenv for your python, you need to deactivate it or point npm to use the OS's own python 2 installation for node-gyp to work.
EDIT:
Had another encounter with the same bug a few days ago. This time around node-gyp was not at fault. Apparently the module I was installing has a dependency on a very old version of node-gyp (v1), independent of the system's version (v3.8), which my version of node (v10) no longer supports. Since I did not need that module anymore, I removed it. Alternatively, you may wish to upgrade/downgrade/replace the offending module, or upgrade/downgrade your node. For the OP's case, the offending module was bcrypt@0.8.5.
After trying many solutions, what worked for me is uninstalling node, n, npm and nvm. The reinstalling nvm and installing node with it. I was following this answer:
How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
Painful and long, but working.
if you want to upgrade Node to 10 or above, you have to find dependencies out of date with Node 10 in package.json and upgrade these packages to newer stable version, then build (npm/yarn install).
来源:https://stackoverflow.com/questions/38058386/why-is-node-gyp-rebuild-failing-on-mac-osx-el-capitan