[Node.js] Node.js のバージョン管理ツール nodebrew を Mac にインストールする方法
重岡 正 · Sun, October 16, 2011
Node.js のバージョン管理ツール nodebrew を Mac にインストールする方法をご紹介します。
nodebrew のインストール
% curl https://raw.github.com/hokaccha/nodebrew/master/nodebrew | perl - setup
.zshrc または .bashrc に以下を追記します。
export PATH=$HOME/.nodebrew/current/bin:$PATH
再読み込み
% source ~/.bashrc
インストールが成功したか確認
% nodebrew help
あとは Node.js をインストールするだけです。
% nodebrew stable
ただし、途中で色々な問題が発生する場合があるので、以下の内容を参考にしてみてください。
error: could not configure a cxx compiler!
% nodebrew install v0.6.21
fetch: http://nodejs.org/dist/v0.6.21/node-v0.6.21.tar.gz
######################################################################## 100.0%
Checking for program g++ or c++ : not found
/Users/your_username/.nodebrew/src/node-v0.6.21/wscript:273: error: could not configure a cxx compiler!
gcc をインストールします。 ・kennethreitz/osx-gcc-installer · GitHub
Checking for openssl : not found
openssl がインストール済みなのに「Checking for openssl : not found」と表示される問題は、pkg-config をインストールすると解決します。
% brew install pkg-config
Build failed: -> task failed (err #2)
以下のようなエラーで Node.js がインストールできない場合は Command Line Tools が入っていないのが原因なのでインストールします。
% nodebrew install v0.6.21
...(省略)...
make[1]: *** [src/unix/darwin.o] Error 1
Waf: Leaving directory `/Users/your_username/.nodebrew/src/node-v0.6.21/out'
Build failed: -> task failed (err #2):
{task: uv uv.h -> uv.a}
make: *** [program] Error 1
Command Line Tools は以下からインストールできます。
Xcode -> Preferences -> Downloads -> Command Line Tools
以上、Node.js のバージョン管理ツール nodebrew を Mac にインストールした現場からお送りしました。