Luke P. Issac
Luke P. Issac

Reputation: 1591

node-gyp rebuild fails on Mac OS High Sierra while npm install

I am getting following error in the terminal, while it tries to install one of package "node-expat". I have tried switching to different node version using nvm but still it is failing with same error.

gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/node-expat
npm ERR! node v6.5.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-expat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-expat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     c:\<redacted>\npm-debug.log

I went ahead installing x-code as suggested on git hub page, on my machine and then it is giving following error,. Not sure how to debug further.

xcode-select: error: tool 'xcodebuild' requires Xcode, 
but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Upvotes: 7

Views: 5748

Answers (2)

StefaDesign
StefaDesign

Reputation: 959

Solution above mentioned by Luke worked partially for me (MacOS) but created another issue : gyp ERR! stack Error:makefailed with exit code: 2 which was solved by removing locked json file. Issue was created due to permission in MAC OS. So if you have xcode re-installed already, open terminal (command line) and type:

xcode-select --reset

then go to your project folder and remove: package-lock.json Now in terminal reinstall project :

npm install

I hope this helps someone!

Upvotes: 3

Luke P. Issac
Luke P. Issac

Reputation: 1591

I just got it fixed on my machine and my fellow colleagues machine.

Followed the following steps to fix it on MacOS highSierra 10.13:

  1. Downloaded command line tools (MacOS 10.13) for xcode and installed it. Download it from "https://developer.apple.com/download/more/"
  2. Installed xcode 10.0 from the app store. Opened xcode and went through the regular configuration xcode does in the initial start up.
  3. After this it started giving "xcode-select" path issue as stated in the description above. On running command "xcode-select --print-path" it was showing path as '/ Library/Developer/CommandLineTools', so i went ahead and tried "xcode-select --reset" after which the path changed to "/Applications/Xcode.app/Contents/Developer". Immediately after it the build started working without any issues.

Upvotes: 6

Related Questions