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

后端 未结 8 2144
囚心锁ツ
囚心锁ツ 2020-12-30 22:50

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 dur

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 23:21

    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!

提交回复
热议问题