Raspberry Pi に google-home-notifier を入れた時に躓いたメモ
Raspberry Pi に google-home-notifier を入れた時にいろいろと躓いたメモ
>> 素のラズパイへ入れようとしました(一部、ディレクトリ名は伏せ字です)
【先に結論】
node.js と npm と google-home-notifier を入れる前にやっておくべき事
(別の素のラズパイで、上記をインストールしてからは問題なしでした)
gitが入っていなければ
# apt-get install git
こちらを参考に node.js と npm をインストール
# apt-get update
# apt-get install nodejs npm
# npm cache clean
# npm install npm n -g
>> 素のラズパイへ入れようとしました(一部、ディレクトリ名は伏せ字です)
【先に結論】
node.js と npm と google-home-notifier を入れる前にやっておくべき事
- sudo ではなく su や sudo -s で root になっておくとトラブル少ないかも
- 下記が入っていない場合は、入れておく
# apt-get install git
# apt-get install libavahi-compat-libdnssd-dev
(別の素のラズパイで、上記をインストールしてからは問題なしでした)
gitが入っていなければ
# apt-get install git
こちらを参考に node.js と npm をインストール
# apt-get update
# apt-get install nodejs npm
# npm cache clean
# npm install npm n -g
ここで ssh へ入り直したほうがよい??
# n stable
途中で README がねー とか WARN が2つほど出ますが無視(して問題無さそう)
こちら や こちら を参考に google-home-notifier をインストール
としたわけですが # npm install でエラーがドバーッっと
これ node が無ぇ、、、のが原因なので
# ln -s /usr/bin/nodejs /usr/bin/node
で、先ほど入れた nodejs へ node からシンボリックリンクを張ってやります
これで # npm install をやってみる・・・・ なんだか快調にスクロールしてるじゃん
あれ、なんか同じ内容を繰り返してね?→コピペーしてみる→ウギャーーループしてるだけ
(ctrl+c とかで殺します)
↓ループしてる一部
展開したディレクトリに権限がないのに無限にリトライしているようなので
google-home-notifier を置いたフォルダに戻って
# cd ../
# chown -R root google-home-notifier
と、持ち主を変更、再度
後で思ったのだが $ sudo -s で作業するとこうなるみたい # su で root になってから作業するべき
# cd google-home-notifier
# npm install
でなんとか入ったもよう
よしよし、テスト起動
# node example.js
またまたエラー → モジュールが足りないぜ
※ su で root になってから(sudo だと またループするぜー)
# npm install --unsafe-perm mdns
エラ~ fatal error: dns_sd.h: そのようなファイルやディレクトリはありません
↓
# apt-get install libavahi-compat-libdnssd-dev
再度
# npm install --unsafe-perm mdns → 時間のかかる build へ進んでいればOK
問題なければ続けて
# npm rebuild --unsafe-perm
やっと
# node example.js
起動しているっぽいので、別の ssh を開いて
$ curl -X POST -d "text=OK Google" http://127.0.0.1:8080/google-home-notifier
アドレス部は、ラズパイのアドレス
ところで、 node example.js を起動すると、サンプルが出て ngrok 経由でどこからでも使えるっぽい
※ngrok のサブドメインは起動毎に変動する
が、どこからでも使える必要がない = ngrok を使わないなら
example.js の下記の箇所をコメントアウト
# n stable
途中で README がねー とか WARN が2つほど出ますが無視(して問題無さそう)
こちら や こちら を参考に google-home-notifier をインストール
としたわけですが # npm install でエラーがドバーッっと
- >>>>> /google-home-notifier# npm install
- npm WARN package.json google-home-notifier@1.2.0 No repository field.
- /
- > mdns@2.3.3 install /hogehoge/google-home-notifier/node_modules/mdns
- > node-gyp rebuild
- make: Entering directory '/hogehoge/google-home-notifier/node_modules/mdns/build'
- CXX(target) Release/obj.target/dns_sd_bindings/src/dns_sd.o
- In file included from ../src/dns_sd.cpp:1:0:
- ../src/mdns.hpp:32:20: fatal error: dns_sd.h: そのようなファイルやディレクトリはありません
- #include <dns_sd .h="">
- ^
- compilation terminated.
- dns_sd_bindings.target.mk:132: recipe for target 'Release/obj.target/dns_sd_bindings/src/dns_sd.o' failed
- make: *** [Release/obj.target/dns_sd_bindings/src/dns_sd.o] Error 1
- make: Leaving directory '/hogehoge/google-home-notifier/node_modules/mdns/build'
- gyp ERR! build error
- gyp ERR! stack Error: `make` failed with exit code: 2
- gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
- gyp ERR! stack at ChildProcess.emit (events.js:98:17)
- gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:12)
- gyp ERR! System Linux 4.9.35+
- gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
- gyp ERR! cwd /hogehoge/google-home-notifier/node_modules/mdns
- gyp ERR! node -v v0.10.29
- gyp ERR! node-gyp -v v0.12.2
- gyp ERR! not ok
- npm WARN This failure might be due to the use of legacy binary "node"
- npm WARN For further explanations, please read
- /usr/share/doc/nodejs/README.Debian
- npm ERR! mdns@2.3.3 install: `node-gyp rebuild`
- npm ERR! Exit status 1
- npm ERR!
- npm ERR! Failed at the mdns@2.3.3 install script.
- npm ERR! This is most likely a problem with the mdns 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 their info via:
- npm ERR! npm owner ls mdns
- npm ERR! There is likely additional logging output above.
- npm ERR! System Linux 4.9.35+
- npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
- npm ERR! cwd /hogehoge/google-home-notifier
- npm ERR! node -v v0.10.29
- npm ERR! npm -v 1.4.21
- npm ERR! code ELIFECYCLE
- npm ERR!
- npm ERR! Additional logging details can be found in:
- npm ERR! /hogehoge/google-home-notifier/npm-debug.log
- npm ERR! not ok code 0
- </dns_sd>
これ node が無ぇ、、、のが原因なので
# ln -s /usr/bin/nodejs /usr/bin/node
で、先ほど入れた nodejs へ node からシンボリックリンクを張ってやります
これで # npm install をやってみる・・・・ なんだか快調にスクロールしてるじゃん
あれ、なんか同じ内容を繰り返してね?→コピペーしてみる→ウギャーーループしてるだけ
(ctrl+c とかで殺します)
↓ループしてる一部
- gyp WARN EACCES user "root" does not have permission to access the dev dir "/hogehoge/google-home-notifier/node_modules/mdns/.node-gyp/8.8.1"
- gyp WARN EACCES attempting to reinstall using temporary dev dir "/hogehoge/google-home-notifier/node_modules/mdns/.node-gyp"
- gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
- gyp verb command install [ '8.8.1' ]
- gyp verb install input version string "8.8.1"
- gyp verb install installing version: 8.8.1
- gyp verb install --ensure was passed, so won't reinstall if already installed
- gyp verb install version not already installed, continuing with install 8.8.1
- gyp verb ensuring nodedir is created /hogehoge/google-home-notifier/node_modules/mdns/.node-gyp/8.8.1
- gyp WARN EACCES user "root" does not have permission to access the dev dir "/hogehoge/google-home-notifier/node_modules/mdns/.node-gyp/8.8.1"
- gyp WARN EACCES attempting to reinstall using temporary dev dir "/hogehoge/google-home-notifier/node_modules/mdns/.node-gyp"
- gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
- gyp verb command install [ '8.8.1' ]
- gyp verb install input version string "8.8.1"
- gyp verb install installing version: 8.8.1
- gyp verb install --ensure was passed, so won't reinstall if already installed
- gyp verb install version not already installed, continuing with install 8.8.1
- gyp verb ensuring nodedir is created /hogehoge/google-home-notifier/node_modules/mdns/.node-gyp/8.8.1
展開したディレクトリに権限がないのに無限にリトライしているようなので
google-home-notifier を置いたフォルダに戻って
# cd ../
# chown -R root google-home-notifier
と、持ち主を変更、再度
後で思ったのだが $ sudo -s で作業するとこうなるみたい # su で root になってから作業するべき
# cd google-home-notifier
# npm install
でなんとか入ったもよう
よしよし、テスト起動
# node example.js
- module.js:515
- throw err;
- ^
- Error: Cannot find module '../build/Release/dns_sd_bindings'
- at Function.Module._resolveFilename (module.js:513:15)
- at Function.Module._load (module.js:463:25)
- at Module.require (module.js:556:17)
- at require (internal/module.js:11:18)
- at Object.<anonymous> (/hogehoge/google-home-notifier/node_modules/mdns/lib/dns_sd.js:32:22)
- at Module._compile (module.js:612:30)
- at Object.Module._extensions..js (module.js:623:10)
- at Module.load (module.js:531:32)
- at tryModuleLoad (module.js:494:12)
- at Function.Module._load (module.js:486:3)
- </anonymous>
またまたエラー → モジュールが足りないぜ
※ su で root になってから(sudo だと またループするぜー)
# npm install --unsafe-perm mdns
エラ~ fatal error: dns_sd.h: そのようなファイルやディレクトリはありません
↓
# apt-get install libavahi-compat-libdnssd-dev
再度
# npm install --unsafe-perm mdns → 時間のかかる build へ進んでいればOK
問題なければ続けて
# npm rebuild --unsafe-perm
やっと
起動しているっぽいので、別の ssh を開いて
$ curl -X POST -d "text=OK Google" http://127.0.0.1:8080/google-home-notifier
アドレス部は、ラズパイのアドレス
ところで、 node example.js を起動すると、サンプルが出て ngrok 経由でどこからでも使えるっぽい
※ngrok のサブドメインは起動毎に変動する
が、どこからでも使える必要がない = ngrok を使わないなら
example.js の下記の箇所をコメントアウト
- var express = require('express');
- var googlehome = require('./google-home-notifier');
- // var ngrok = require('ngrok'); ←ココ
- var bodyParser = require('body-parser');
- var app = express();
- // (略)
- app.listen(serverPort, function () {
- /* ココから
- ngrok.connect(serverPort, function (err, url) {
- console.log('POST "text=Hello Google Home" to:');
- console.log(' http://localhost:' + serverPort + '/google-home-notifier');
- console.log(' ' +url + '/google-home-notifier');
- console.log('example:');
- console.log('curl -X POST -d "text=Hello Google Home" ' + url + '/google-home-notifier');
- });
- ココまで
- */
- })
コメント