This one bit me too. There were several different solutions, only one of them worked for me.
First, make sure you have the Xcode command line tools installed, as the npm page says.
1) The simplest solution, which, of course, did not work (although it looks like it was for some people), you just need to delete the ~/.node-gyp . So you can also take this snapshot as well as remove your node_modules dir and do another npm install .
2) Try removing node -gyp and reinstalling:
sudo npm uninstall node-gyp -g npm uninstall node-gyp npm install
3). But what trick was the solution is given in the node -gyp problem on github , where you need to install another version of node and make your npm that way. This is simpler than it sounds, but it's pretty rude:
sudo npm cache clean -f sudo npm install -gn sudo n 4.4.5 sudo npm install npm -g sudo npm uninstall node-gyp -g
Then try running npm install.
Hope this helps!
source share