KUSAMAKURA

智に働けば角が立つ。情に棹させば流される。意地を通せば窮屈だ。とかくに人の世は住みにくい。

Windows で Hubot を動かす

Node.js のインストール

nodejs.org からインストーラ落として、ウィザードに従うだけで完了。 特に落とし穴もありませんでしたが、 「Node.js」のインストール を参考にしました。

Hubotのインストール

hubot

HUBOT をインストールします。TOP のロボットには何事かをしてくれそうな異常なワクワク感があります。

コマンドプロンプトでの作業になります。適当な作業ディレクトリを作成してください。

cd c:\
mkdir hubotwork
cd hubotwork
npm install -g hubot
Error: ENOENT, stat 'C:\Users\[user]\AppData\Roaming\npm'

あらら。エラーになってしまいました。AppData 配下ってあたりで何となく察しますが、Node.js/Windows error: ENOENT, stat 'C:\Users\RT\AppData\Roaming\npm' の記事によると、Node.js のインストーラのバグのようですね。

  1. 管理者権限でコマンドプロンプトを起動
  2. 指定のディレクトを作成('C:\Users[user]\AppData\Roaming\npm')
  3. 管理者権限でコマンドを再実行

とのこと。そういや、そもそも管理者権限でコマンドプロンプト起動してなかった。気を取り直して最初から。

スタートメニューからコマンドプロンプトのショートカットを右クリックして、「管理者として実行...」を選択

cd c:\hubotwork
mkdir c:\Users\[user]\AppData\Roaming\npm
npm install -g hubot
npm ERR! network connect ETIMEDOUT
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "hubot"
npm ERR! cwd c:\hubot
npm ERR! node -v v0.10.36
npm ERR! npm -v 1.4.28
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     c:\hubot\npm-debug.log
npm ERR! not ok code 0

また、エラーですね。なるほど、Proxy 設定し忘れてました。 [Node.js] npm の proxy と registry 設定 を参考にして、Proxy の設定を行います。

npm -g config set proxy http://[proxy host]:[proxy port]
npm -g config set https-proxy http://[proxy host]:[proxy port]
npm -g config set registry http://registry.npmjs.org/
npm install -g hubot
hubot@2.11.0 node_modules\hubot
├── readline-history@1.2.0
├── log@1.4.0
├── optparse@1.0.4
├── scoped-http-client@0.10.0
├── coffee-script@1.6.3
└── express@3.18.1 (basic-auth@1.0.0, fresh@0.2.4, merge-descriptors@0.0.2, u
tils-merge@1.0.0, escape-html@1.0.1, cookie@0.1.2, range-parser@1.0.2, cookie-si
gnature@1.0.5, media-typer@0.3.0, parseurl@1.3.0, methods@1.1.0, vary@1.0.0, con
tent-disposition@0.5.0, depd@1.0.0, debug@2.1.1, etag@1.5.1, proxy-addr@1.0.6, c
ommander@1.3.2, mkdirp@0.5.0, send@0.10.1, connect@2.27.1)

ついでに、coffee-script, generator-hubot もインストールしておきます。

npm install -g coffee-script
npm install -g generator-hubot

今度は成功したっぽい。一応、ディレクトリを確認します。

dir c:\Users\[user]\AppData\Roaming\npm\node_modules
 ドライブ C のボリューム ラベルは OS です
 ボリューム シリアル番号は B87A-26C2 です

 c:\Users\[user]\AppData\Roaming\npm\node_modules のディレクトリ

2015/02/04  13:57    <DIR>          .
2015/02/04  13:57    <DIR>          ..
2015/02/04  13:55    <DIR>          coffee-script
2015/02/04  13:57    <DIR>          generator-hubot
2015/02/04  13:53    <DIR>          hubot
2015/02/04  13:57    <DIR>          yo
               0 個のファイル                   0 バイト
               6 個のディレクトリ  302,825,226,240 バイトの空き領域

今回はグローバルオプションを指定しましたが、install 時に -g オプションを指定しなければ、実行したディレクトリにインストールされているはずです。

動作確認

hubot のヘルプオプションが実行できればとりあえず、OKかと思います。

hubot --help
Usage hubot [options]

Available options:
  -a, --adapter ADAPTER   The Adapter to use
  -c, --create PATH       Create a deployable hubot
  -d, --disable-httpd     Disable the HTTP server
  -h, --help              Display the help information
  -l, --alias ALIAS       Enable replacing the robot's name with alias
  -n, --name NAME         The name of the robot in chat
  -r, --require PATH      Alternative scripts path
  -t, --config-check      Test hubot's config to make sure it won't fail at startup
  -v, --version           Displays the version of hubot installed