`npm install` fails on node-gyp rebuild with `gyp: No Xcode or CLT version detected!`

前端 未结 13 1499
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 12:56

Every time I try npm install. I get the following error. How do I fix it?

gyp: No Xcode or CLT version detected!

I am on n

13条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 13:19

    I guess, you may have tried multiple solutions so far but if none of those solutions have worked for you yet, don't worry - I got you. :)

    Non-working Solutions:

    1. xcode-select --install didn't work for me (macOS Catalina 10.15.7) as it shows up a Software Update dialog box which says Can't install the software because it is currently not available from the Software Update Server.
    2. I also downloaded and install Xcode Command Line Tools from Apple's download website (https://developer.apple.com/download/more/?=for%20Xcode) but the problem re-appeared somehow or may be it didn't solve it in first place and I somehow didn't notice.
    3. sudo xcode-select --reset also didn't do the trick for me.
    4. Someone suggested to install whole XCode. No, thank you.

    Working Solution:

    Here is what worked for me i.e. reinstall Xcode Command Line Tools using Software Update manually.

    1. Check if Command Line Tools Update is mentioned in your list of softwares to be updated by using following command: softwareupdate -l
    2. If Command Line Tools Update is not mentioned in that list, then manually make it part of the list using following command which will create a temporary file: sudo touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
    3. Verify that the list now has the Command Line Tools mentioned by running softwareupdate -l again.
    4. Now, press Cmd+Space to initiate Mac's Spotlight Search. Search for Software Update. Start the Software Update.
    5. That will show you following kind of dialog for installing the Command Line Tools. Install away the update and be merry. :)
    6. Remove the temporary file created in Step 2: sudo rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress.

提交回复
热议问题