$ nvm
Node Version Manager
Usage:
nvm help Show this message
nvm install <version> Download and install a <version>
nvm uninstall <version> Uninstall a version
nvm use <version> Modify PATH to use <version>
<<以下略>>
$ nvm install 0.8.15
######################################################################## 100.0%
Now using node v0.8.15
$
2. node.jsがインストールできたことを確認
node -vコマンドを実行すると、node.jsのバージョンが表示されます。
$ node -v
v0.8.15
$
3. サーバプログラムを動かして動作を確認する
node.jsで、簡単なサーバプログラムを動かしてみます。
次の内容のファイル node_test.js を用意します。
ファイルnode_test.js:
varhttp=require('http');http.createServer(function(req,res){res.writeHead(200,{'Content-type':'text/plain'});res.end('Hello World\n');}).listen(5001,'0.0.0.0');console.log('Server running at http://localhost');