'command failed: tar' when running 'npm install phantomjs'

As part of installing phantomjs when buoilding a development environment for Magento 2 I encountered a problem where it failed to install. The error presented to me was

Error: Command failed: tar jxf /usr/lib/node_modules/phantomjs/phantomjs/phantomjs-{version}.tar.bz2

I was able to run tar, and tar was in my $PATH, so I was confused about the problem.

Turns out because the file was a bzip one, it was trying to execute bzip2 within tar, hence why it seemed like tar was failing.

Simple answer: yum/dnf/apt-get install bzip2


Tags: npmnodelinux