Syntax Error.

[Sy] Node-RED を Mac にインストールする(yarn利用)

2018/02/02

Node-REDMac にインストールする手順です。

1. 作業用ディレクトリを作成

まず作業用のディレクトリを適当に作ります。

$ mkdir node-red-test
$ cd node-red-test

(省略可)一応 package.json を作っておきます。

$ npm init -y
Wrote to /Users/utano320/Documents/Develop/node-red-test/package.json:

{
  "name": "node-red-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

2. Node-RED をインストール

今回は yarn を使ってインストールしてみます。

$ yarn add node-red
yarn add v1.2.1
info No lockfile found.
[1/4] 🔍  Resolving packages...
warning node-red > node-red-node-email > nodemailer@1.11.0: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
warning node-red > i18next > i18next-client@1.10.3: you can use npm install i18next from version 2.0.0
warning node-red > node-red-node-feedparser > request > node-uuid@1.4.8: Use uuid module instead
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "1.3.2" while you're on "1.2.1".
info To upgrade, run the following command:
$ brew upgrade yarn
success Saved 314 new dependencies.
・
・
・
✨  Done in 6.77s.

(↓ npm の場合はこれで)

$ npm install node-red

インストールはこれだけです。簡単ですね。

3. 起動

Node-RED を起動します。実行バイナリは以下のパスにあります。

$ ./node_modules/node-red/bin/node-red-pi
2 Feb 23:51:58 - [info]

Welcome to Node-RED
===================

2 Feb 23:51:58 - [info] Node-RED version: v0.18.1
2 Feb 23:51:58 - [info] Node.js  version: v8.9.4
2 Feb 23:51:58 - [info] Darwin 16.7.0 x64 LE
2 Feb 23:51:58 - [info] Loading palette nodes
2 Feb 23:51:59 - [warn] ------------------------------------------------------
2 Feb 23:51:59 - [warn] [node-red/rpi-gpio] Info : Ignoring Raspberry Pi specific node
2 Feb 23:51:59 - [warn] ------------------------------------------------------
2 Feb 23:51:59 - [info] Settings file  : /Users/utano320/.node-red/settings.js
2 Feb 23:51:59 - [info] User directory : /Users/utano320/.node-red
2 Feb 23:51:59 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
2 Feb 23:51:59 - [info] Flows file     : /Users/utano320/.node-red/flows_utano320noMacBook-Pro.local.json
2 Feb 23:51:59 - [info] Creating new flow file
2 Feb 23:51:59 - [info] Server now running at http://127.0.0.1:1880/
2 Feb 23:51:59 - [info] Starting flows
2 Feb 23:51:59 - [info] Started flows

起動しました。

ブラウザで http://localhost:1880 にアクセスすると、以下のように Node-RED の画面が確認できるはずです。

Node-RED 起動画面