回答編集履歴
2
追記: コンソール出力
answer
CHANGED
@@ -15,10 +15,85 @@
|
|
15
15
|
Raspbian: 2017-11-29-raspbian-stretch-lite.zip
|
16
16
|
node v8.9.3 (lts)
|
17
17
|
|
18
|
+
- node.js は、nvmを使用して、lts版をインストールしました。
|
18
19
|
|
20
|
+
|
21
|
+
### 参考: 実行した際のコンソール出力
|
19
|
-
-
|
22
|
+
- 実行例: nodeのインストール
|
23
|
+
|
20
24
|
```
|
21
|
-
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.7/install.sh | bash
|
25
|
+
pi@raspberrypi:~ $ curl -s -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.7/install.sh | bash
|
26
|
+
=> Downloading nvm as script to '/home/pi/.nvm'
|
27
|
+
|
28
|
+
=> Appending nvm source string to /home/pi/.bashrc
|
29
|
+
=> Appending bash_completion source string to /home/pi/.bashrc
|
30
|
+
=> Close and reopen your terminal to start using nvm or run the following to use it now:
|
31
|
+
|
32
|
+
export NVM_DIR="$HOME/.nvm"
|
33
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
34
|
+
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
22
|
-
source ~/.bashrc
|
35
|
+
pi@raspberrypi:~ $ source ~/.bashrc
|
23
|
-
nvm install --lts && node --version
|
36
|
+
pi@raspberrypi:~ $ nvm install --lts && node --version
|
37
|
+
Installing latest LTS version.
|
38
|
+
Downloading and installing node v8.9.3...
|
39
|
+
Downloading https://nodejs.org/dist/v8.9.3/node-v8.9.3-linux-armv7l.tar.xz...
|
40
|
+
######################################################################## 100.0%
|
41
|
+
Computing checksum with sha256sum
|
42
|
+
Checksums matched!
|
43
|
+
Creating default alias: default -> lts/* (-> v8.9.3)
|
44
|
+
v8.9.3
|
45
|
+
```
|
46
|
+
|
47
|
+
- 実行例: milkcocoaのnodeパッケージインストール、アプリ作成、実行
|
48
|
+
|
49
|
+
```
|
50
|
+
pi@raspberrypi:~ $ mkdir mytestapp
|
51
|
+
pi@raspberrypi:~ $ cd mytestapp
|
52
|
+
pi@raspberrypi:~/mytestapp $ time npm install milkcocoa
|
53
|
+
|
54
|
+
> bufferutil@1.2.1 install /home/pi/mytestapp/node_modules/bufferutil
|
55
|
+
> node-gyp rebuild
|
56
|
+
|
57
|
+
make: Entering directory '/home/pi/mytestapp/node_modules/bufferutil/build'
|
58
|
+
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
|
59
|
+
SOLINK_MODULE(target) Release/obj.target/bufferutil.node
|
60
|
+
COPY Release/bufferutil.node
|
61
|
+
make: Leaving directory '/home/pi/mytestapp/node_modules/bufferutil/build'
|
62
|
+
|
63
|
+
> utf-8-validate@1.2.2 install /home/pi/mytestapp/node_modules/utf-8-validate
|
64
|
+
> node-gyp rebuild
|
65
|
+
|
66
|
+
make: Entering directory '/home/pi/mytestapp/node_modules/utf-8-validate/build'
|
67
|
+
CXX(target) Release/obj.target/validation/src/validation.o
|
68
|
+
SOLINK_MODULE(target) Release/obj.target/validation.node
|
69
|
+
COPY Release/validation.node
|
70
|
+
make: Leaving directory '/home/pi/mytestapp/node_modules/utf-8-validate/build'
|
71
|
+
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/mytestapp/package.json'
|
72
|
+
npm notice created a lockfile as package-lock.json. You should commit this file.
|
73
|
+
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/mytestapp/package.json'
|
74
|
+
npm WARN mytestapp No description
|
75
|
+
npm WARN mytestapp No repository field.
|
76
|
+
npm WARN mytestapp No README data
|
77
|
+
npm WARN mytestapp No license field.
|
78
|
+
|
79
|
+
+ milkcocoa@0.7.0
|
80
|
+
added 45 packages in 41.013s
|
81
|
+
|
82
|
+
real 0m43.085s
|
83
|
+
user 0m22.560s
|
84
|
+
sys 0m1.370s
|
85
|
+
pi@raspberrypi:~/mytestapp $ cat <<EOF > test.js
|
86
|
+
> var MilkCocoa = require('milkcocoa');
|
87
|
+
> var milkcocoa = new MilkCocoa('applejb2g3tnb.mlkcca.com');
|
88
|
+
> var ds = milkcocoa.dataStore('test');
|
89
|
+
> ds.on("push", function(data){
|
90
|
+
> console.log(data.value.message);
|
91
|
+
> });
|
92
|
+
> ds.push({message:'Hello World!'});
|
93
|
+
> EOF
|
94
|
+
pi@raspberrypi:~/mytestapp $
|
95
|
+
pi@raspberrypi:~/mytestapp $ node ./test.js
|
96
|
+
Hello World!
|
97
|
+
^C
|
98
|
+
pi@raspberrypi:~/mytestapp $
|
24
99
|
```
|
1
途中で送信してしまった
answer
CHANGED
@@ -1,7 +1,24 @@
|
|
1
1
|
marumoriさん、
|
2
2
|
|
3
3
|
この部分は、書き換えましたか?
|
4
|
+
milkcocoaのサイトにて、アプリ作成後、アプリの名前をクリックすると、概要のページにでています。
|
5
|
+
|
4
6
|
```
|
5
7
|
// your-app-idの部分は、Milkcocoaに(無料)登録してアプリを作成した際に生成されるアプリ固有の文字列です。
|
6
8
|
var milkcocoa = new MilkCocoa('your-app-id.mlkcca.com');
|
9
|
+
```
|
10
|
+
|
11
|
+
|
12
|
+
以下の環境にて、test.js の動作を確認できました。
|
13
|
+
|
14
|
+
Raspberry Pi 3 Model B
|
15
|
+
Raspbian: 2017-11-29-raspbian-stretch-lite.zip
|
16
|
+
node v8.9.3 (lts)
|
17
|
+
|
18
|
+
|
19
|
+
- node.js は、nvmを使用して、lts版をインストールしました。
|
20
|
+
```
|
21
|
+
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.7/install.sh | bash
|
22
|
+
source ~/.bashrc
|
23
|
+
nvm install --lts && node --version
|
7
24
|
```
|