node-gyp: node-gyp rebuild failed on MacOS
- Node Version: node v10.4.0 npm 6.1.0
- Platform: MacOS
- Compiler: Apple LLVM version 10.0.0 (clang-1000.10.25.5)
- Module:
Verbose output (from npm or node-gyp):
> node-gyp rebuild
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
Some strange behavior: When I use the npm script to run the node-gyp would rebuild failed, but ./node_modules/node-gyp/bin/node-gyp.js
will run ok.
$ xcode-select -p /Library/Developer/CommandLineTools
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 38 (6 by maintainers)
@spjsschl
I fixed the
$ xcodebuild -version
error doing the following:I’m troubleshooting another problem with
npm install
Hope that worksUPDATE: I got away with the
npm install
error described by @aguynamedben by switching the active environment to one running python 2.7 (I got the error while the active env had python 3.6)This was the only way I was able to solve this. manually setting this in Xcode settings:
deleting my lock file, node_modules folder then reinstalling with
npm install
resolved my issueI’m seeing this with:
I don’t have XCode installed, but I do have the Command Line Tools installed. It seems like node-gyp is having an issue determining something about the XCode environment (xcode_emulation.py).
I’m installing XCode and will try after that.
Any ideas?
binding.gyp: https://gist.github.com/aguynamedben/f46b059e5551afebd964da130614d78c
Command that is failing:
Error:
macOS version: High Sierra, 10.13.6
I just had this problem. After some diagnosis, I was able to just update the version for node-gyp inside the
package-lock.json
.I’ve never had to edit the file directly before, but mine was throwing the exact same error as the one posted here by realdennis.
Mine was
node-sass
failing and it was depending on node-gyp v3.3.Here is the code inside my package-lock.json for reference and context:
I simply changed it from 3.3 to 3.7 and my
npm install
was able to complete successfully.In case it helps anybody, for me downgrading node (installed with brew) to LTS (v10.13.0) worked.
Running
sudo xcode-select --switch /Library/Developer/CommandLineTools
fixed it for meAfter trying most of the above, what ended up working for me was, believe it or not, simply updating node to the latest version.
Depending on the dependencies of your particular project, you may not be able to use the latest stable version of node, but you can try upgrading to the latest version your project allows and see if it resolves the issue as it did for me.
I faced this when I updated my macOS to Catalina. It is fixed 🎉
yarn.lock
/package-lock.json
filesyarn
Yep, if you upgrade to 3.6.3 or 3.7.0 things should work. I’ll go ahead and close this out but let me know if you still have issues after upgrading.
For those upgrading to macOS Catalina, please checkout #1940
I’ve tried several solutions and this one seems working: https://blog.greggant.com/posts/2018/01/10/node-sass-fails-installing.html
This worked for me
xcode_emulation.py in XcodeVersion
version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
AttributeError: ‘NoneType’ object has no attribute ‘groups’Verbose output
This works for me
npm install -g n n 8.8.1
sudo npm explore npm -g – npm install node-gyp@latest
Downgrading from Python3.xx to Python2.xx fixed the issue
This helped to fix the issue
ok, so for me the following worked, when running
Xcode version
i got thisThis usually happens when MacOs has an update to Xcode, just open Xcode and see if you need to install some additional stuff, after doing this I was golden.
It looks like yesterday Apple released some updates to High Sierra and Command Line Tools… going to try them now and post back if it’s still happening.
Yesterday I was also trying with only Command Line Tools installed, now I’ve installed full XCode, so that will also be impacting my 2nd attempt.
@aguynamedben
I’m having the same issue with macOS version: High Sierra, 10.13.6, Node v11.0.0 when running
npm rebuild node-sass
. Let me know if you’ve managed to fix it somehow.@Vipinunnikrishnan after 2h searching for answers, yours worked for me! Ty
@alexanmtz that link solved it for me! Thanks 😃
The same issue as @teddis except I have node-pre-gyp instead of node-gyp. I was just trying to run an open source project, didn’t know it would turn into this. Any ideas?
Following up… some combination of installing full XCode and updating my Command Line Tools fixed this for me.
Maybe https://github.com/refack/GYP/pull/1 would address this, or at least provide a more meaningful error message.