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

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

新規登録して質問してみよう
ただいま回答率
85.50%
Raspberry Pi

Raspberry Piは、ラズベリーパイ財団が開発した、名刺サイズのLinuxコンピュータです。 学校で基本的なコンピュータ科学の教育を促進することを意図しています。

Q&A

解決済

1回答

2466閲覧

milkcocoaをインストールできない

marumori

総合スコア8

Raspberry Pi

Raspberry Piは、ラズベリーパイ財団が開発した、名刺サイズのLinuxコンピュータです。 学校で基本的なコンピュータ科学の教育を促進することを意図しています。

0グッド

0クリップ

投稿2017/12/11 07:45

編集2017/12/11 08:37

ラズベリーパイ3を用いて、milkcocoaを利用しようと考えています。

しかし、npm install milkcocoaと入力すると以下のようなエラーが出ます。

pi@raspberrypi:~ $ npm install milkcocoa > usb@1.3.1 install /home/pi/node_modules/usb > node-pre-gyp install --fallback-to-build node-pre-gyp ERR! Tried to download(404): https://github.com/tessel/node-usb/releases/download/1.3.1/usb_bindings-v1.3.1-node-v57-linux-arm.tar.gz node-pre-gyp ERR! Pre-built binaries not found for usb@1.3.1 and node@8.6.0 (node-v57 ABI, glibc) (falling back to source compile with node-gyp) make: Entering directory '/home/pi/node_modules/usb/build' CC(target) Release/obj.target/libusb/libusb/libusb/core.o CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o CC(target) Release/obj.target/libusb/libusb/libusb/io.o CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o CC(target) Release/obj.target/libusb/libusb/libusb/sync.o CC(target) Release/obj.target/libusb/libusb/libusb/os/poll_posix.o CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_udev.o ../libusb/libusb/os/linux_udev.c:40:21: fatal error: libudev.h: そのようなファイルやディレクトリはありません #include <libudev.h> ^ compilation terminated. libusb.target.mk:132: recipe for target 'Release/obj.target/libusb/libusb/libusb/os/linux_udev.o' failed make: *** [Release/obj.target/libusb/libusb/libusb/os/linux_udev.o] Error 1 make: Leaving directory '/home/pi/node_modules/usb/build' gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23) gyp ERR! stack at emitTwo (events.js:125:13) gyp ERR! stack at ChildProcess.emit (events.js:213:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) gyp ERR! System Linux 4.4.34-v7+ gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/pi/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/home/pi/node_modules/usb/src/binding" gyp ERR! cwd /home/pi/node_modules/usb gyp ERR! node -v v8.6.0 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/pi/node_modules/usb/src/binding' (1) node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/pi/node_modules/node-pre-gyp/lib/util/compile.js:83:29) node-pre-gyp ERR! stack at emitTwo (events.js:125:13) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:213:7) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:927:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) node-pre-gyp ERR! System Linux 4.4.34-v7+ node-pre-gyp ERR! command "/usr/local/bin/node" "/home/pi/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /home/pi/node_modules/usb node-pre-gyp ERR! node -v v8.6.0 node-pre-gyp ERR! node-pre-gyp -v v0.6.39 node-pre-gyp ERR! not ok Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/pi/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/pi/node_modules/usb/src/binding' (1) npm WARN pi@1.0.0 No description npm WARN pi@1.0.0 No repository field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: xpc-connection@0.1.4 (node_modules/xpc-connection): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for xpc-connection@0.1.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: usb@1.3.1 (node_modules/usb): npm WARN optional SKIPPING OPTIONAL DEPENDENCY: usb@1.3.1 install: `node-pre-gyp install --fallback-to-build` npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1 + milkcocoa@0.7.0 updated 1 package in 79.584s

ご教示ねがいます。

(追記)
node.jsのバージョンを5.5.1にダウングレードし、再度インストール行いました。その後、milkcocoaをインストールすると、エラーは出ませんでしたが、動作テスト> http://blog.mlkcca.com/iot/realtime-data-visualization-with-raspberry-pi-1/でmilkcocoaメソッドが動きませんでした。

pi@raspberrypi:~/work/milkgraph $ sudo npm install -g milkcocoa + milkcocoa@0.7.0 updated 1 package in 6.313s
var MilkCocoa = require('milkcocoa'); // your-app-idの部分は、Milkcocoaに(無料)登録してアプリを作成した際に生成されるアプリ固有の文字列です。 var milkcocoa = new MilkCocoa('your-app-id.mlkcca.com'); var ds = milkcocoa.dataStore('test'); ds.on("push", function(data){ console.log(data.value.message); }); ds.push({message:'Hello World!'});
pi@raspberrypi:~/work/milkgraph $ node test.js →(本来出てくるはずのHelloWorldが出ず、、、)

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

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

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

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

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

guest

回答1

0

ベストアンサー

marumoriさん、

この部分は、書き換えましたか?
milkcocoaのサイトにて、アプリ作成後、アプリの名前をクリックすると、概要のページにでています。

// your-app-idの部分は、Milkcocoaに(無料)登録してアプリを作成した際に生成されるアプリ固有の文字列です。 var milkcocoa = new MilkCocoa('your-app-id.mlkcca.com');

以下の環境にて、test.js の動作を確認できました。

Raspberry Pi 3 Model B
Raspbian: 2017-11-29-raspbian-stretch-lite.zip
node v8.9.3 (lts)

  • node.js は、nvmを使用して、lts版をインストールしました。

参考: 実行した際のコンソール出力

  • 実行例: nodeのインストール
pi@raspberrypi:~ $ curl -s -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.7/install.sh | bash => Downloading nvm as script to '/home/pi/.nvm' => Appending nvm source string to /home/pi/.bashrc => Appending bash_completion source string to /home/pi/.bashrc => Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion pi@raspberrypi:~ $ source ~/.bashrc pi@raspberrypi:~ $ nvm install --lts && node --version Installing latest LTS version. Downloading and installing node v8.9.3... Downloading https://nodejs.org/dist/v8.9.3/node-v8.9.3-linux-armv7l.tar.xz... ######################################################################## 100.0% Computing checksum with sha256sum Checksums matched! Creating default alias: default -> lts/* (-> v8.9.3) v8.9.3
  • 実行例: milkcocoaのnodeパッケージインストール、アプリ作成、実行
pi@raspberrypi:~ $ mkdir mytestapp pi@raspberrypi:~ $ cd mytestapp pi@raspberrypi:~/mytestapp $ time npm install milkcocoa > bufferutil@1.2.1 install /home/pi/mytestapp/node_modules/bufferutil > node-gyp rebuild make: Entering directory '/home/pi/mytestapp/node_modules/bufferutil/build' CXX(target) Release/obj.target/bufferutil/src/bufferutil.o SOLINK_MODULE(target) Release/obj.target/bufferutil.node COPY Release/bufferutil.node make: Leaving directory '/home/pi/mytestapp/node_modules/bufferutil/build' > utf-8-validate@1.2.2 install /home/pi/mytestapp/node_modules/utf-8-validate > node-gyp rebuild make: Entering directory '/home/pi/mytestapp/node_modules/utf-8-validate/build' CXX(target) Release/obj.target/validation/src/validation.o SOLINK_MODULE(target) Release/obj.target/validation.node COPY Release/validation.node make: Leaving directory '/home/pi/mytestapp/node_modules/utf-8-validate/build' npm WARN saveError ENOENT: no such file or directory, open '/home/pi/mytestapp/package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open '/home/pi/mytestapp/package.json' npm WARN mytestapp No description npm WARN mytestapp No repository field. npm WARN mytestapp No README data npm WARN mytestapp No license field. + milkcocoa@0.7.0 added 45 packages in 41.013s real 0m43.085s user 0m22.560s sys 0m1.370s pi@raspberrypi:~/mytestapp $ cat <<EOF > test.js > var MilkCocoa = require('milkcocoa'); > var milkcocoa = new MilkCocoa('applejb2g3tnb.mlkcca.com'); > var ds = milkcocoa.dataStore('test'); > ds.on("push", function(data){ > console.log(data.value.message); > }); > ds.push({message:'Hello World!'}); > EOF pi@raspberrypi:~/mytestapp $ pi@raspberrypi:~/mytestapp $ node ./test.js Hello World! ^C pi@raspberrypi:~/mytestapp $

投稿2017/12/11 17:04

編集2017/12/11 17:22
mt08

総合スコア1825

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

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

marumori

2017/12/11 17:08

早速の回答ありがとうございます。 はい。milkcocoaにログインをして、app-idを取得し、上記のコードに書き込みました。しかし、hello worldが帰って来ません。
marumori

2017/12/11 17:09

明日もう一度試してみます。 ありがとうございます。
mt08

2017/12/11 17:22

コンソール出力を追記しました。参考にしてみてください。
marumori

2017/12/12 05:10

上記の回答を参考にしてみましたが、やはり値が帰って来ません。 ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー pi@raspberrypi:~ $ curl -s -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.7/install.sh | bash => nvm is already installed in /home/pi/.nvm, trying to update using git => * (detached from v0.33.7) master => Compressing and cleaning up git repository => Appending nvm source string to /home/pi/.bashrc => Appending bash_completion source string to /home/pi/.bashrc N/A: version "N/A -> N/A" is not yet installed. You need to run "nvm install N/A" to install it before using it. => You currently have modules installed globally with `npm`. These will no => longer be linked to the active version of Node when you install a new node => with `nvm`; and they may (depending on how you construct your `$PATH`) => override the binaries of modules installed with `nvm`: /usr/local/lib ├── cylon-ble@0.10.1 ├── express@4.16.2 ├── milkcocoa@0.7.0 ├── n@2.1.8 => If you wish to uninstall them at a later point (or re-install them under your => `nvm` Nodes), you can remove them from the system Node as follows: $ nvm use system $ npm uninstall -g a_module => Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー pi@raspberrypi:~/mytestapp $ time npm install milkcocoa npm WARN pi@1.0.0 No description npm WARN pi@1.0.0 No repository field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: xpc-connection@0.1.4 (node_modules/xpc-connection): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for xpc-connection@0.1.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"}) + milkcocoa@0.7.0 added 1 package and updated 1 package in 33.26s real 0m35.631s user 0m31.740s sys 0m1.710s ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー やはり、milkcocoaが正しくインストールされていないのでしょうか?
marumori

2017/12/12 05:16

新しくアプリを作成し、app-idを書き換えたところうまく値が帰ってきました。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問