質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
npm

npmは、Node Packaged Modulesの略。Node.jsのライブラリ・パッケージを管理できるツールです。様々なモジュールを簡単にインストールでき、自分でモジュールを作成し公開する際にも使用できます。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Q&A

解決済

1回答

1935閲覧

(Mac)npmからbleaconがインストール出来ない

piaxwg

総合スコア10

npm

npmは、Node Packaged Modulesの略。Node.jsのライブラリ・パッケージを管理できるツールです。様々なモジュールを簡単にインストールでき、自分でモジュールを作成し公開する際にも使用できます。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

0グッド

0クリップ

投稿2018/11/17 16:36

編集2018/11/23 05:16

前提・実現したいこと

Macをibeacon化するために下記のQiitaのページを参考に、
homebrewやnodebrewなどをインストールして、bleaconをインストールしようとしていました。

npm install bleaconを実行したところ、下記のエラーメッセージが出力されました。
エラーメッセージの4行目辺りにあるように、XcodeのCommandLineToolsに原因があるようなメッセージだったのですが、
homebrewインストール後にbrew doctorコマンドで "Your system is ready to brew"が表示されたことや、
softwareupdateコマンドで、アップデート可能なソフトウェアを探しても、無いと出力されてしまいます。

何か他に見落としていることや、解決策があればご教示いただけるとありがたいです。
よろしくお願いします。

発生している問題・エラーメッセージ

エラーメッセージ $ npm install bleacon > xpc-connection@0.1.4 install /Users/xxxxxxxx/ibeacon/node_modules/xpc-connection > 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 Traceback (most recent call last): File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module> sys.exit(gyp.script_main()) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main return main(sys.argv[1:]) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main return gyp_main(args) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 523, in gyp_main generator.GenerateOutput(flat_list, targets, data, params) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2170, in GenerateOutput part_of_all=qualified_target in needed_targets) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 795, in Write self.Pchify)) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1190, in WriteSources cflags = self.xcode_settings.GetCflags(configname) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 551, in GetCflags archs = self.GetActiveArchs(self.configname) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 420, in GetActiveArchs xcode_archs_default = GetXcodeArchsDefault() File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 118, in GetXcodeArchsDefault xcode_version, _ = XcodeVersion() File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1265, in XcodeVersion version = re.match(r'(\d.\d.?\d*)', version).groups()[0] AttributeError: 'NoneType' object has no attribute 'groups' gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16) gyp ERR! stack at emitTwo (events.js:126:13) gyp ERR! stack at ChildProcess.emit (events.js:214:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12) gyp ERR! System Darwin 18.2.0 gyp ERR! command "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/bin/node" "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/xxxxxxxx/ibeacon/node_modules/xpc-connection gyp ERR! node -v v8.9.3 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok > bignum@0.11.0 install /Users/xxxxxxxx/ibeacon/node_modules/bignum > node-gyp configure build 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 Traceback (most recent call last): File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module> sys.exit(gyp.script_main()) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main return main(sys.argv[1:]) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main return gyp_main(args) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 523, in gyp_main generator.GenerateOutput(flat_list, targets, data, params) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2170, in GenerateOutput part_of_all=qualified_target in needed_targets) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 795, in Write self.Pchify)) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1190, in WriteSources cflags = self.xcode_settings.GetCflags(configname) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 551, in GetCflags archs = self.GetActiveArchs(self.configname) File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 420, in GetActiveArchs xcode_archs_default = GetXcodeArchsDefault() File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 118, in GetXcodeArchsDefault xcode_version, _ = XcodeVersion() File "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1265, in XcodeVersion version = re.match(r'(\d.\d.?\d*)', version).groups()[0] AttributeError: 'NoneType' object has no attribute 'groups' gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16) gyp ERR! stack at emitTwo (events.js:126:13) gyp ERR! stack at ChildProcess.emit (events.js:214:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12) gyp ERR! System Darwin 18.2.0 gyp ERR! command "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/bin/node" "/Users/xxxxxxxx/.nodebrew/node/v8.9.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build" gyp ERR! cwd /Users/xxxxxxxx/ibeacon/node_modules/bignum gyp ERR! node -v v8.9.3 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok npm WARN enoent ENOENT: no such file or directory, open '/Users/xxxxxxxx/ibeacon/package.json' npm WARN ibeacon No description npm WARN ibeacon No repository field. npm WARN ibeacon No README data npm WARN ibeacon No license field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: bluetooth-hci-socket@0.5.1 (node_modules/bluetooth-hci-socket): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for bluetooth-hci-socket@0.5.1: wanted {"os":"linux,android,win32","arch":"any"} (current: {"os":"darwin","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: xpc-connection@0.1.4 (node_modules/xpc-connection): npm WARN optional SKIPPING OPTIONAL DEPENDENCY: xpc-connection@0.1.4 install: `node-gyp rebuild` npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! bignum@0.11.0 install: `node-gyp configure build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the bignum@0.11.0 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /Users/xxxxxxxx/.npm/_logs/2018-11-17T14_26_09_432Z-debug.log

試したこと

①homebrewやnodebrew、node.jsのインストール
(http://mmorley.hatenablog.com/entry/2016/11/22/233034)
上記を参考に、homebrewなどのインストールをしました。
インストール時にhomebre doctorで"Your system is ready to brew."が出力されることを確認。

//以下記入が漏れていたため追記(2018.11.23)
②nodebrewをインストールし、そこからさらにnode.jsをインストール
(※Qiitaのいくつかの記事でバージョンが新しすぎるとbleaconがインストールできない旨の記事を見かけたので
v8.9.3やv8.11.3をインストールし使用するようnodebrewから設定)
(https://qiita.com/n0bisuke/items/e6298f13be6822965045)

③ターミナルでnpm install bleaconを入力してbleaconをインストールしようとしたところ、
上記の発生しているエラーメッセージの

xcode-select: error: tool 'xcodebuild'~

が出力されたことから、ターミナル上でMacのソフトウェアでアップデート可能なものを検索
(ターミナルでsoftwareupdate -lを入力)したところアップデートが可能なソフトウェアはない旨のメッセージが出力された

Software Update Tool

Finding available software
No new software available.

そもそもソフトウェアのアップデートなどが必要な場合、①のhomebrewのインストール時に
brew doctorコマンドで何かしらのエラーが出力されると思われるので、
ソフトウェアのアップデートが必要だとは思われない。
(使用しているOSが2018年11月18日時点で最新のMojaveのため、対応していない可能性あり?)

補足情報(FW/ツールのバージョンなど)

各ソフトウェアのバージョンは以下の通りです。
MacOS:10.14.1(Mojave)
Xcode:10.1
homebrew:1.8.2
nodebrew:8.9.4
node.js:8.9.3
npm:5.6.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

bleaconのインストールは自己解決することが出来ました。

####原因
npmのnode-gypのバージョンが古いために発生したエラーであり、
バージョンを上げると解決できるようです。

####試したこと
ネットでnpmのインストールでバージョンに関するエラーを探したところ
アップルのsupport communitiesで類似のエラーに関するものを発見しました。
npm gyp error on Mojave

1件ある回答を見ると...

Take a look at https://github.com/nodejs/node-gyp/issues/1464. In your case, npm is using node-gyp v3.6.2. According the aforementioned link, this issue is resolved in 3.6.3 or higher. To change the version of node-gyp bundled with your installation of npm, take a look at https://github.com/nodejs/node-gyp/wiki/Updating-npm's-bundled-node-gyp

これをgoogle先生に翻訳してもらうと

https://github.com/nodejs/node-gyp/issues/1464をご覧ください。あなたの場合、npmはnode-gyp v3.6.2を使用しています。前述のリンクによれば、この問題は3.6.3以上で解決されています。 npmのインストールでバンドルされたnode-gypのバージョンを変更するには、https://github.com/nodejs/node-gyp/wiki/Updating-npm's- bundle-node-gypを参照してください。

となり、記載された[リンク](https://github.com/nodejs/node-gyp/wiki/Updating-npm's- bundle-node-gyp)をクリックすると、githubのページとび、もちろん英語なので、またまたグーグル先生に翻訳してもらったところ

npmはノード-gypのそれ自身の、内部の、コピーを束ねます。この内部コピーは、npm install -g node-gypを介してインストールした可能性がある、グローバルにインストールされたnode-gypのコピーとは独立しています。

つまり、デフォルトで$ PATHにnode-gypがインストールされていない間も、ネイティブアドオンをnpmにインストールしようとすると、npmは独自のコピーを保持して起動します。
場合によっては、npmの内部ノード-gypを、インストールされているものよりも新しいバージョンに更新する必要があるかもしれません。単純なnpm install -g node-gypは、npmが引き続きグローバルなものよりも内部コピーを使い続けるので、このトリックを行いません。

とのことだったので、
どうページ内に記載されていたコマンド(今回はMacなので、Linux,MacOSX,Solaris,etc.と記載がある箇所)

$ [sudo] npm explore npm -g -- npm install node-gyp@latest

をターミナルに入力したところ、アップデートが開始され、最終的に

$ npm explore npm -g -- npm install node-gyp@latestnpm notice created a lockfile as package-lock.json. You should commit this file.

が表示され無事にアップデート出来ました。
で、その後npm bleacon installでbleaconをインストールすることも出来ました。

正直ドがつくほどの初心者なので(汗、グローバルなインストールとか深いことはわからなかったのですが、node-gypは複数存在していて、一般的にアップデートに使用されるコマンド(npm update -g npm?)では、npmが使用するnode-gypのバージョンを上げられないというように認識しました。
ここに来るまでに何か間違いがあれば、指摘していただけるとありがたいです。

ちなみに...Bleaconのインストールまではできましたが、
この後、ibeaconの送受信ができないと言うトラブルが発生して、
現在解決策を探しております(笑
また質問を投稿するかもしれません

####あとがき
これまでjavascriptなどを使って開発をしたことがなく、ちょっと作ってみたいものが出てきたので、
その開発をするための環境を整備するだけでも、一苦労するとは思いませんでした。
でもネットで調べたりすることによって、ある程度は解決(解決しなくても近づくことが)できると
わかったのは勉強になりました。

同様の症状で困っている方の手助けになれば&備忘録として記事を投稿することにしました。

ここまでたどり着くために、色々なページを渡り歩きましたが、それぞれのページにかなり
助けられました。一つ一つ全てのページに対してお礼を言うことはできませんが、ここで
まとめてお礼をさせてください。ありがとうございましたm(_ _)m

そして、ここまで読んでくださりありがとうございました。

投稿2018/11/23 06:16

編集2018/11/23 06:21
piaxwg

総合スコア10

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問