node-webkitおもしろいね

おもろいなー、と思ったのでメモ。

nodeでWindows / Mac / Linuxで動くデスクトップアプリケーションを作れるらしい。
V8の上でnode.jsを動かしているっぽいのでChrome packaged appみたいなイメージか。

Hello world

npmでインストールできる。ただ、githubにある最新のバージョンより古かったのが気になる感じ。(githubは0.8.3で、npmは0.8.2-1だった。)
グローバルにインストールして使うこともできるが、作者的には各アプリケーション毎に対応するバージョンのnodewebkitを使うことを推奨するとのこと。

$ npm install nodewebkit

おもむろにpackage.jsonを書く。

{
    "name": "hello world"
    , "main": "index.html"
    , "script": {
        "start": "nodewebkit"
    }
}

ついでにindex.htmlも書く。

<!DOCTYPE html>
<html lang="ja">
<head>
    <title>hello world</title>
</head>
<body>
    <p>hello world!</p>
</body>
</html>

$ npm start で動く。

f:id:weathercook:20131227022825p:plain

簡単〜。

Nodeクックブック

Nodeクックブック