node.jsのバージョンアップサイクルは割と短い為、バージョン管理システムを利用して管理したほうが便利です。
今回はnaveを利用します。
gitからcloneします。適当なディレクトリでOKです。
1 |
git clone git://github.com/isaacs/nave.git |
nave.shというファイルが保存されます。このshを実行してnode.jsのバージョン管理をします。
まずは何も考えずに./nave.shしてみましょう。下記のヘルプが表示されます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Usage: nave <cmd> Commands: install <version> Install the version passed (ex: 0.1.103) use <version> Enter a subshell where <version> is being used use <ver> <program> Enter a subshell, and run "<program>", then exit use <name> <ver> Create a named env, using the specified version. If the name already exists, but the version differs, then it will update the link. usemain <version> Install in /usr/local/bin (ie, use as your main nodejs) clean <version> Delete the source code for <version> uninstall <version> Delete the install for <version> ls List versions currently installed ls-remote List remote node versions ls-all List remote and local node versions latest Show the most recent dist version help Output help information <version> can be the string "latest" to get the latest distribution. <version> can be the string "stable" to get the latest stable version. |
簡単に和訳しておきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
使い方: nave <cmd> コマンド: install <version> 与えられたバージョンのnode.jsをインストール (ex: 0.1.103) use <version> <version> で渡されたバージョンを利用する use <ver> <program> <ver>で与えられたバージョンでを実行する use <name> <ver> <ver>で与えられた環境を作成する。もしnameが既に存在していた場合、かつバージョンが違う場合はアップデートされる usemain <version> /usr/local/binにインストールされる (ie, メインのnodejsとして利用するなど) clean <version> <version>のソースコードを削除する uninstall <version> <version>のインストールを削除する ls 既にインストールされているバージョンを一覧する ls-remote リモートのnodeのバージョンを一覧する ls-all リモートとローカルのバージョンを一覧する latest 最新のバージョンを見る help このhelpを出力する <version>は "latest" のような文字列も使用可能で、その場合は最新のバージョンとなります <version>は"stable"のような文字列も使用可能で、その場合は最新の安定版となります |
という事で、使用する場合は
1 |
./nave.sh use 0.9.0 |
などとすればOKです。その時点で環境変数に登録され、nodeコマンドが利用出来るようになります。