LoginSignup
10
10

More than 5 years have passed since last update.

node-gyp を使う npm install でコケる

Posted at
  • Node.js 0.10.24
  • Marverick
  • Command Line Tools はインストールしてるけど Xcode はインストールしてない

といった環境で node-gyp を使う npm をインストールしようとすると、こんなエラーが出てこけました。

$ npm install phantom --save
(略)
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

gyp: Error 1 running xcodebuild
gyp ERR! configure error
(以下略)

エラーメッセージで検索してみたら、node-gyp の issue Problems on Mavericks with only Command Line Tools installed · Issue #341 · TooTallNate/node-gyp が引っかかりました。

内容を読むと、これは node だとか node-gyp の問題ではなく、gyp の問題だと書いてあります。で、gyp 側のこのコミットで修正されてるんじゃないのとのこと。

この修正は node への Pull Request としてマージされているので、次のリリースでは問題なく動くようになるんじゃないかと思います。

で、そのリリースが来るまでどうするかというと、自力でパッチを当てます。変更するファイルは /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py あたりです。

比較的見やすいこのコミットを参考に、 を_GetSdkVersionInfoItem_AdjustLibrary を書き換えてやれば動くようになります。

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10