
[node.js]Windowsに、node.jsをインストールする(Cygwin)
※追記
Node.js、Microsoftの協力を得てWindowsへ正式移植 
無理にインストールするより、上記を待った方がいいかも。
※追記2
Node.jsがバージョンアップ、初の公式Windows版「node.exe」登場
バイナリが出ました。
参考) https://github.com/ry/node/wiki/Building-node.js-on-Cygwin-(Windows)
■Cygwinをインストール
http://www.cygwin.com/
参考) http://www.db.is.kyushu-u.ac.jp/rinkou/cygwin/cygwin.html
cygwin 導入パッケージでは以下を選択
| 1 2 3 4 5 6 7 8 9 | ・Web    → wget ・devel  → gcc-g++ ・devel  → git ・devel  → make ・devel  → openssl ・libs   → openssl-devel ・devel  → pkg-config ・devel  → zlib-devel ・python → python | 
環境変数「PATH」 に「C:cygwiusrbin;C:cygwinusrlocalbin」を追可
※これをちゃんと設定しておかないと、このあと「ash」上で ls すら実行できない
■Cygwinを起動しnode.jsをインストール……できない?
一応、resolv.confを設定しておく
| 1 2 3 | $ vim /etc/resolv.conf nameserver 8.8.8.8 nameserver 8.8.4.4 | 
node.jsダウンロード
http://nodejs.org/
| 1 2 3 | $ wget http://nodejs.org/dist/node-v0.3.1.tar.gz  $ tar xvf /node-v0.3.1.tar.gz  $ cd node-v0.3.1 | 
node.js インストール準備 ライブラリチェック
| 1 | $ ./configure | 
しかし、以下のようなエラーが出てconfigureが通らない。
| 1 2 3 4 | 5 [main] python 2244 C:cygwinbinpython.exe: *** fatal error - unable to remap \?C:cygwinlibpython2.6lib-dynloadtime.dll to same address as parent: 0x2D0000 != 0x3C0000< 11 [main] python 3392 fork: child 2244 - died waiting for dll loading, errno 11 wscript:165: error: could not configure a c compiler! | 
こまったときは、Google。
■ash上でnode.jsをインストールする
参考) http://avalanche123.com/post/855374337/nodejs-mongodb-tinyurl
いったんCygwinを終了する。
以下のフォルダからash.exeを起動
| 1 | C:cygwin/bin/ash.exe | 
ash上でrebaseallを実行
| 1 | $ rebaseall | 
自分の環境ではここでTempに書き込めないとエラーがでた
| 1 | rebaseall: '/cygdrive/c/Users/hoge/AppData/Local/Temp' is not writable | 
rebaseallをエディタで開きテンポラリの指定フォルダを変更して再度ash上でrebaseallを実行
| 1 2 | #TmpDir="${TMP:-${TEMP:-/tmp}}" TmpDir="/tmp" | 
メッセージがなにも出力されないので成功したのか失敗したのかわかりにくいが、コマンドが正しく実行されるとちょっと待たされたのちコンソールに操作が戻る。
そのままash上で node-v0.3.1ディレクトリに移動し改めてconfigre実行
| 1 | $ ./configure | 
いろいろ見つからないライブラリもあるけれど、とりあえず
「’configure’ finished successfully」
が表示されればビルドできるので、makeする。
| 1 2 | $ make $ make install | 
■Cygwinを起動しmake test
ashを終了し、cygwinを起動、 node-v0.3.1 ディレクトリへ移動しテスト開始
| 1 | $ make test 2>&1 | tee node-test.log | 
node.jsサイトのサンプルをテストしてみる。
| 1 2 3 4 5 6 7 | //example.js var http = require('http'); http.createServer(function (req, res) {   res.writeHead(200, {'Content-Type': 'text/plain'});   res.end('Hello Worldn'); }).listen(8124, "127.0.0.1"); console.log('Server running at http://127.0.0.1:8124/'); | 
| 1 | $ node example.js | 
ブラウザでhttp://127.0.0.1:8124/にアクセスし、「Hello World」と表示されれば完了
上記の方法は、多数の「not found」が出たままビルドしてしまっているのでうまく動かないAPIが結構あるかも。