LoginSignup
3
2

More than 5 years have passed since last update.

node-red-contrib-alexa-home-skillインストール[On Onion Omega2+]

Last updated at Posted at 2018-06-29

image.png

先日、Onion Omega2 Plus に Node-Red をインストールしました。
その後、この環境に「node-red-contrib-alexa-home-skill」をインストールしたので、記録として残しておきます。
尚、npm コマンドでインストールの際、Out Of Memory が発生してしまいましたが、ググって回避できました。

0. 前提条件

  • Onion Omega2 Plus
    • BusyBox v1.26.2
    • Ω-ware: 0.1.10 b160(標準リポジトリの2018/06/24時点最新版)
    • Linux 4.4.46 mipsel LE
  • 2GB Micro-SD Card
    • パーティション2分割
      • 512MB=スワップ用、残り=システム領域拡張用
  • Omega2拡張ドック
  • Node.js version: v4.3.1
  • Node-RED version: v0.18.4
  • Onion OS(この作業には関係ないけど、今回の環境ではインストール済み)

1. インストール

通常(?)は、Node-Red の[設定]→[パレット]→[ノードを追加]から node-red-contrib-alexa-home-skill を検索して、インストールすれば良いのですが、インストールできませんでした。
そこで、npm コマンドでのインストールを行ってみましたが、以下のようにOut Of Memory が発生してしまいました。どうも、46.5MB の上限に達したため、エラーになっているようでした。

エラーログ
root@Omega-xxxx:~/.node-red# npm install node-red-contrib-alexa-home-skill
npm WARN package.json node-red-project@0.0.1 No repository field.
npm WARN package.json node-red-project@0.0.1 No README data
npm WARN package.json node-red-project@0.0.1 No license field.
/
<--- Last few GCs --->

  365719 ms: Scavenge 26.6 (46.5) -> 26.6 (46.5) MB, 3.5 / 0 ms (+ 34.1 ms in 1 steps since last GC) [allocation failure] [incremental marking delaying mark-sweep].
  366991 ms: Mark-sweep 26.6 (46.5) -> 26.4 (46.5) MB, 1272.0 / 0 ms (+ 34.1 ms in 1 steps since start of marking, biggest step 34.1 ms) [last resort gc].
  368264 ms: Mark-sweep 26.4 (46.5) -> 26.4 (46.5) MB, 1272.7 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x27f24d59 <JS Object>
    2: resolve [url.js:426] [pc=0x274eb098] (this=0x775f4461 <an Url with map 0x3bd36e65>,relative=0x27f088a9 <String[1]: .>)
    3: resolve(aka urlResolve) [url.js:422] [pc=0x274eadf8] (this=0x490181e9 <an Object with map 0x3bd6bec5>,source=0x775f449d <String[21]: //registry.npmjs.org/>,relative=0x27f088a9 <String[1]: .>)
    4: toNerfDart(aka toNerfDart) [/usr/lib/node_modules/npm/lib/config/nerf...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
Aborted

Googleで検索したところ、以下の記事を見つけることができました。

npm install - javascript heap out of memory
image.png

この記事では、--max_old_space_size オプションで、npm install 時のメモリ割り当てを変更できるようなことが記載されていました。
そこで、実際に以下のコマンドで実行してみました。

Console
root@Omega-xxxx:~# cd ~/.node-red
root@Omega-xxxx:~/.node-red# node --max_old_space_size=512 $(which npm) install node-red-contrib-alexa-home-skill

実行結果は、以下のとおり成功です。
node-red-contrib-alexa-home-skill をインストールできました。
私は、512MB 割り当てましたが、topコマンドで利用メモリ量を見ていた感じ、最大 100MB 程度だったので、128MB でも大丈夫だと思います。

実行結果
root@Omega-xxxx:~/.node-red# node --max_old_space_size=512 $(which npm) install node-red-contrib-alexa-home-skill
npm WARN package.json node-red-project@0.0.1 No repository field.
npm WARN package.json node-red-project@0.0.1 No README data
npm WARN package.json node-red-project@0.0.1 No license field.
node-red-contrib-alexa-home-skill@0.1.17 node_modules/node-red-contrib-alexa-home-skill
tqq body-parser@1.18.3 (content-type@1.0.4, bytes@3.0.0, depd@1.1.2, qs@6.5.2, on-finished@2.3.0, raw-body@2.3.3, http-errors@1.6.3, debug@2.6.9, type-is@1.6.16, iconv-lite@0.4.23)
tqq request@2.87.0 (aws-sign2@0.7.0, oauth-sign@0.8.2, tunnel-agent@0.6.0, forever-agent@0.6.1, is-typedarray@1.0.0, caseless@0.12.0, safe-buffer@5.1.2, aws4@1.7.0, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.1, performance-now@2.1.0, qs@6.5.2, uuid@3.3.2, combined-stream@1.0.6, mime-types@2.1.18, tough-cookie@2.3.4, form-data@2.3.2, http-signature@1.2.0, har-validator@5.0.3)
mqq mqtt@2.18.2 (inherits@2.0.3, reinterval@1.1.0, xtend@4.0.1, minimist@1.2.0, concat-stream@1.6.2, split2@2.2.0, commist@1.0.0, end-of-stream@1.4.1, pump@3.0.0, mqtt-packet@5.6.0, readable-stream@2.3.6, websocket-stream@5.1.2, help-me@1.1.0)

2. 確認

Node-Redに接続して Alexaのノードがあることを確認します。
ちゃんと、Alexaノードが確認できました。
image.png

次回は、フロー作成の手順に進みたいと思います。
※前回の記事で node-red-contrib-alexa-local をインストールと記載しましたが、 node-red-contrib-alexa-local は、ON/OFF制御のみをサポートとのことで、もっと細かい制御が可能な node-red-contrib-alexa-home-skill にしました。ちなみに node-red-contrib-alexa-local は、Node-Redの設定画面からインストールできました。

以上

3
2
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
3
2