Is it possible to do a complete, clean, uninstall of Phantom JS after it has been compiled in place?
It seems that PhantomJS—by default—doesn’t install it’s files anywhere outside of it’s build directory. According to the official PhantomJS documentation on building the software:
This produces a statically built
bin/phantomjs
. This is a self-contained executable, it can be moved to a different directory or another machine.
Which means that if you did a git clone
of the source software to a directory named phantomjs/
and then ran ./build.sh
in that directory, you can just remove the bin/
directory in phantomjs/
. Or just get rid of the whole phantomjs/
directory and pull a new git clone
to attempt to build it again.
But honestly, when I recently faced the task of installing PhantomJS on Ubuntu 12.04, I winced at the idea of dealing with source code build taking hours to compile. So I installed PhantomJS via NPM (Node Package Manager)—which is a part of NodeJS instead. This gives you a nice, clean, already “built” version of PhantomJS in minutes instead of waiting hours for the build/compile to manually finish.
This is how I did it in Ubuntu 12.04:
First, install Node.js and NPM (Node Package Manager)
Install python-software-properties
like this:
sudo apt-get install python-software-properties
Next add the NodeSource PPA repository to the system like this:
curl -sL https://deb.nodesource.com/setup | sudo bash -
With that done, run aptitude
update like this:
sudo aptitude update
And now, install Node.js and NPM like this:
sudo aptitude install nodejs
Now NodeJS and NPM will be installed. You can check the versions by running the following commands:
nodejs --version
npm --version
The returned versions should be v0.10.33
for NodeJS and 1.4.28
for NPM.
Next, install PhantomJS via NPM (Node Package Manager)
Now install PhantomJS via NPM like this:
sudo npm install -g phantomjs
Or use this variant of the command which uses phantomjs-prebuilt
if you find phantomjs
to be depreciated when you run the NPM command:
sudo npm install -g phantomjs-prebuilt
After it installs check the version by running this command:
phantomjs --version
The version number should be something like 1.9.8
.
If that somehow fails, then set the NPM registry like this:
npm config set registry http://registry.npmjs.org/
And if there are SSL issues connecting to the NPM repository, disable the strict SSL settings:
npm config set strict-ssl false
Once that’s all done, you will have PhantomJS installed successfully via NPM.
UPDATE: The original poster indicates that they are compiling PhantomJS for use on a Raspberry Pi. If that is the case, one can install NodeJS and NPM on a Raspberry Pi via the methods explained here as well as here.
Related videos on Youtube
realtebo
Updated on September 18, 2022Comments
-
realtebo almost 2 years
I’ve just built and compiled PhantomJS for use on a Raspberry Pi.
To do this, I cloned the GitHub repository, than used a
build.sh
command that—after 5 hours—has generated few executables, copied or moved other few files, and so on.I think build is not 100% successful, so I’d like to restart.
I there a way to undo a PhantomJS build?
-
realtebo over 9 yearsSuper answer, thanks. But my Linux is, for precision because I omitted this info, a raspberry pi. So there is no legacy binary package on node package repository usefull for my little friend.
-
Giacomo1968 over 9 yearsYou can install NodeJS and NPM on a Raspberry Pi. Clearly explained here as well as here.
-
realtebo over 9 yearsBut I cannot install phantomJs using npm. Has some strange errors about using phantomJs as a dependency of phantomJs itselfs
-
maxime1992 over 8 yearsSmall update,
phantomjs
is now deprecated with npm so you should rather installnpm install -g phantomjs-prebuilt
-
Giacomo1968 over 8 years@Maxime Thanks for the tip! Just updated the answer.