Ubuntu16.04 にPhantomJSをnodeでインストールする際にエラーになる

Posted on 2017/01/01 in tech

詰まったのでメモ。

$ sudo npm install -g phantomjs

実行

> phantomjs@2.1.7 install /usr/local/lib/node_modules/phantomjs\ > node install.js

sh: 1: node: not found\ npm ERR! Linux 4.4.0-51-generic\ npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "-g" "install" "phantomjs"\ npm ERR! node v4.2.6\ npm ERR! npm v3.5.2

あちゃー。

解決策がgithubに記載されていた。

https://github.com/Medium/phantomjs#im-on-debian-or-ubuntu-and-the-installer-failed-because-it-couldnt-find-node

Some Linux distros tried to rename node to nodejs due to a package conflict. This is a non-portable change, and we do not try to support this. The official documentation recommends that you run apt-get install nodejs-legacy to symlink node to nodejs on those platforms, or many NodeJS programs won't work properly.

ので、nodejs-legacyをインストールする。

$ sudo apt-get install nodejs-legacy

これでphantomjsをインストールできるようになった。めでたしめでたし。