0.11.16
と 0.12.7
でインストール時の挙動が違ったのでメモ。
結論
npm i -g casperjs@1.1.0-beta3
echo 'PHANTOMJS_EXECUTABLE=$HOME/.nodebrew/current/lib/node_modules/casperjs/node_modules/phantomjs/bin/phantomjs' >> ~/.bash_profile
source ~/.bash_profile
詳細
0.12.7の場合、そもそもインストール出来ない
npm ERR! notarget No compatible version found: casperjs@'*'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["1.1.0-beta2","1.1.0-beta3"]
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
↑のERRORにしたがって
$ npm i -g casperjs@1.1.0-beta3
とするとインストール可能。(v0.11.16ではバージョン指定は不要だった)
しかしこれだけだと、 $ casperjs
で以下のERRORを吐く。
Fatal: [Errno 2] No such file or directory; did you install phantomjs?
phantomjsのpathを見つけられていないようなので追加。
.bash_profile
PHANTOMJS_EXECUTABLE=$HOME/.nodebrew/current/lib/node_modules/casperjs/node_modules/phantomjs/bin/phantomjs
これでnodebrew環境でも動いた。