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

后端 未结 8 2108
囚心锁ツ
囚心锁ツ 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条回答
  • 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!

    0 讨论(0)
  • 2020-12-30 23:23

    Try looking at your python install.

    I found a hint at the discussion here https://github.com/nodejs/node-gyp/issues/489#issuecomment-431447692.

    My python on my MacBook Pro is managed by Homebrew which installs binaries to

    /usr/local/bin

    So I did the following in terminal:

    >$: npm config set python /usr/local/bin/python
    >$: rm -rf node_modules
    >$: npm i
    
    0 讨论(0)
  • 2020-12-30 23:24

    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).

    0 讨论(0)
  • 2020-12-30 23:31

    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
    
    0 讨论(0)
  • 2020-12-30 23:33

    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/

    0 讨论(0)
  • 2020-12-30 23:35

    I had a similar issue and running the commands below fixed it for me

     Install Xcode // if you dont have it installed already
     Run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    
    0 讨论(0)
提交回复
热议问题