[Node.js] バージョン管理ツール nodebrew を Mac にインストールする方法
- 2012 10/21
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/bakorer/.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/bakorer/.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 – Block Rockin’ Codes
・Installing node.JS on OS X 10.6 | Walt-O-Matic
・node.js – Make errors when installing nodejs on OSX 10.7.4 – Stack Overflow