技術的なメモとか

MacPorts が簡単ということでやってみる。

@ port selfupdate

しばらくまって完了したらこんなメッセージが。

> The ports tree has been updated. To upgrade your installed ports, you should run
>  port upgrade outdated

そうかそうか。
そんな訳で指示通りに実行

@ port upgrade outdated

そしたら

---> Activating perl5 @5.12.3_1+perl5_12
Error: Target org.macports.activate returned: Image error: /opt/local/bin/a2p is being used by the active perl5.8 port. Please deactivate this port first, or use 'port -f activate perl5' to force the activation.
Error: Failed to install perl5
Log for perl5 is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_perl5/perl5/main.log
Error: The following dependencies were not installed: perl5
Error: Unable to upgrade port: 1
To report a bug, see <http://guide.macports.org/#project.tickets>

とか言われる。

@ port installed | grep perl

でインストール済みの perl を調べて

@ port -f deactive perl???
@ port -f uninstall perl???

で片っぱしから消してまた "port upgrade outdated" してみたら、今度は p5.12-locale-gettext でまたエラーが出たのでそれも上記の方法で消す。
そしてまた "port upgrade outdated" すると以下のエラーが。

Error: Target org.macports.install returned: no destroot found at: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_perl_p5-locale-gettext/p5.12-locale-gettext/work/destroot
Log for p5.12-locale-gettext is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_perl_p5-locale-gettext/p5.12-locale-gettext/main.log
Error: Problem while installing p5.12-locale-gettext
To report a bug, see <http://guide.macports.org/#project.tickets>

良く分からんけど destroot ってディレクトリが無ってことらしいので mkdir してまた upgrade したらようやく通った。
と、ここまで数時間を経過し、ようやく node.js のインストールだ!

@ port install nodejs

インストール成功!
リクエストを処理するスクリプトを書く!

vi xx.js
--------------------------------------------------
// http オブジェクトを用意
var http = require('http');

// リクエスト受付時の処理
http.createServer(function (req, res) {
 res.writeHead(200, {'Content-Type': 'text/plain'}); // プレーンテキストで出力する通知
 
 // req オブジェクトが何なのかを知る
 res.write("\n<req>\n");
 for (var key in req) res.write("["+key+"] = "+req[key]+"\n");
 
 // res オブジェクトが何なのかを知る
 res.write("\n<res>\n");
 for (var key in res) res.write("["+key+"] = "+res[key]+"\n");
 
 res.end(); // 処理を終了
}).listen(12345, "127.0.0.1");

// ターミナルに文字列を出力
console.log('Server running at http://127.0.0.1:12345/');
--------------------------------------------------

そして node.js を起動だ!

@ /opt/local/bin/node xx.js

ブラウザから localhost:12345 にアクセスしたらオブジェクトの中身がズラズラと表示されるはず!

さあ次は node.js のパッケージ管理コマンドを入れよう。

@ port install npm

インストール成功!




http://www.atmarkit.co.jp/fwcr/rensai2/nodejs02/02.html

Copyright (C) Takeshi Matsuda. All Rights Reserved.
0.0013070106506348