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

137,545

Solution 1

Even though you have them installed (my case), but by upgrading to Catalina (10.15.*) you can get this error (my case :) ).

Therefore, simply installing wouldn't help as you will get an error that they are already installed.

Therefore you need to hopefully just (I) reset the tool or in worse case (II) uninstall and install (requires large redownload) it again (this is based on the @Dane_duPlessis's answer).

# just for а preview (not necessary)
xcode-select --print-path
# in my case it printed `/Library/Developer/CommandLineTools`

# could be useful if the path is making a problem
sudo xcode-select --switch /Library/Developer/CommandLineTools

# only for the (I) resetting case
sudo xcode-select --reset

# only for the (II) uninstalling case - the next line deletes folder returned by the `xcode-select --print-path` command
sudo rm -rf $(xcode-select --print-path)


# only for the (II) uninstalling case - install tools (again) if you don't get a default installation prompt
xcode-select --install

NOTE:

  • You do not need to do it per project, but only once
  • There was also discussion that you have to do it on every OSX update, in my case, later updating the OSX system didn't trigger this issue again

Credits to: gyp: No Xcode or CLT version detected macOS Catalina

Solution 2

This worked for me with macOS Catalina Version 10.15.5:

$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer
$ sudo xcode-select --switch /Library/Developer/CommandLineTools
...
$ sudo xcode-select --reset
...

The xcode cli tools should now be accessible. No need to re-install anything.

Solution 3

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. :) enter image description here
  6. Remove the temporary file created in Step 2: sudo rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress.

Solution 4

Try these commands:

sudo rm -rf $(xcode-select -print-path)

xcode-select --install

If the above didn't resolve your issue, you may have a problem with the path Xcode is installed at. Use the following to help if necessary.

sudo xcode-select --switch /Library/Developer/CommandLineTools

sudo xcode-select --reset

Solution 5

I was facing the same issue error message

I reinstalled the command line tools.

re installing

You need to find the installation directory.

xcode-select --print-path

Delete the existing installation:

sudo rm -r -f /Library/Developer/CommandLineTools

Install by running:

xcode-select --install
Share:
137,545
Jeena
Author by

Jeena

I am an enthusiastic, software engineer with a passion for using technology in an ethically sustainable way to solve the issues people face daily.

Updated on July 08, 2022

Comments

  • Jeena
    Jeena almost 2 years

    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 node -v → v8.8.0 & npm -v → v6.11.3

    I tried to run it on VSCode terminal and iTerm, but both ended up getting the same error. (both are updated to the latest version). The only new thing I did is updating my macOS to the latest version (Catalina 10.15.3 today).

    $ npm install          Fri Mar  6 17:22:40 2020
    
    > [email protected] install /Users/synapse/Documents/synapsefi-dev-ui/node_modules/watchpack/node_modules/fsevents
    > node-gyp rebuild
    
    No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
    
    No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
    
    No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
    
    gyp: No Xcode or CLT version detected!
    gyp ERR! configure error
    gyp ERR! stack Error: `gyp` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onCpExit (/Users/synapse/.nvm/versions/node/v8.8.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:344:16)
    gyp ERR! stack     at emitTwo (events.js:125:13)
    gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
    gyp ERR! System Darwin 19.3.0
    gyp ERR! command "/Users/synapse/.nvm/versions/node/v8.8.0/bin/node" "/Users/synapse/.nvm/versions/node/v8.8.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /Users/synapse/Documents/synapsefi-dev-ui/node_modules/watchpack/node_modules/fsevents
    gyp ERR! node -v v8.8.0
    gyp ERR! node-gyp -v v5.0.3
    gyp ERR! not ok
    npm WARN [email protected] No repository field.
    npm WARN The package country-data is included as both a dev and production dependency.
    npm WARN The package react-dropzone is included as both a dev and production dependency.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/watchpack/node_modules/fsevents):
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
    
  • fatg
    fatg almost 4 years
    I just found out that whenever Apple pushes an update, it will always result in this error
  • Carter Medlin
    Carter Medlin over 3 years
  • coagmano
    coagmano over 3 years
    Confirming this works on Catalina. Much easier than a full reinstall
  • AHonarmand
    AHonarmand over 3 years
    Running xcode-select --install opens the install dialogue but then when I agree to terms and click on install it fails with: Can't install the software because it is currently not available from the Software Update Server
  • AHonarmand
    AHonarmand over 3 years
    This solved the problem: stackoverflow.com/a/63990975/5112418
  • tonethar
    tonethar over 3 years
    You can download the developer tools from here: developer.apple.com/download/more
  • Siddhant
    Siddhant over 3 years
    Update on my Answer above If you have updated your OS to OSX Catalina 10.15.7 then xcode-select --install might not work. You might get an error saying the software is not found on server. I have found 2 solutions for this Solution 1: If u can afford to have xcode App from App store which is of 11+ GB then you can fix the error. Solution 2; You can download the command line tool from official Apple Developer Account and install it. developer.apple.com/download/more/?=command%20line%20tools
  • CoderUni
    CoderUni over 3 years
    this is better off as a comment rather than an answer because this is a link only answer
  • Magical Gordon
    Magical Gordon over 3 years
    This should be the main answer, no need for a lengthy reinstall. Worked on 10.15.7 Catalina
  • Dayron Gallardo
    Dayron Gallardo over 3 years
    This is the only answer that worked for me. I'm on Mac OS Catalina 10.15.7. Thank you!
  • Bloke
    Bloke over 3 years
    If you too get the Can’t install the software because it is not currently available from the Software Update server error, and if you don't want to install Xcode, as the solution @AHonarmand linked suggests, simply download the command line tools manually from here developer.apple.com/download/more/?=command%20line%20tools -- that's what fixed this for me. EDIT: (Source: developer.apple.com/forums/thread/660641)
  • Ivan Garcia
    Ivan Garcia over 3 years
    This worked for me perfectly!! This should be the correct answer.
  • Jamshad Ahmad
    Jamshad Ahmad about 3 years
    Wish I knew about it before deleting my CommandLines directory.
  • Ricardo
    Ricardo about 3 years
    Worked for me on macOS Catalina v10.15.7. It used to work a year ago, maybe before I upgrade to Catalina.
  • Flavio Andrade
    Flavio Andrade about 3 years
    Just reset worked for me too. I'm using Big Sur 11.2.3.
  • Jost
    Jost about 3 years
    It doesn't work on macOS Big Sur unfortunately. I get xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools' even though it's the correct path.
  • Ian Dunn
    Ian Dunn almost 3 years
    Why is xcode-select --print-path required if the output isn't being used?
  • Steve Bennett
    Steve Bennett almost 3 years
    Duplicate answer.
  • GlenBee
    GlenBee almost 3 years
    Thanks, this worked for me too on Big Sur (MacOS v11.3)
  • Martin Seeler
    Martin Seeler almost 3 years
    This moment, when you just deleted the app, waiting for the reinstall and scroll through the other solutions... god damnit
  • Anh Cao
    Anh Cao over 2 years
    This also works for me. Thank you for saving me a lot of reinstall time.
  • Sergius
    Sergius over 2 years
    Thanks. Every update gets me frustrated. I'd like to dedicate to Apple the same phrase as Linus said to NVidia.
  • Gaurav
    Gaurav over 2 years
    works flawlessly @Akhilesh!
  • dev_in_prog
    dev_in_prog over 2 years
    (I) worked for me, thanks!
  • cyberfly
    cyberfly about 2 years
    Thanks I already upvote but today the same answer help me again, I would upvote again if can
  • Sebastiano Vierk
    Sebastiano Vierk about 2 years
    This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review
  • krummens
    krummens almost 2 years
    It's installing now. Says "About 197 hours, 28 minutes remaining"... gotta love that
  • sp_conway
    sp_conway almost 2 years
    This is what worked for me. Thank you! My command line tools had the correct install path but updating this way is what did the trick.