I need to install the Spidermonkey JS engine on my work machine. The project I\'m working on has a jslint script that requires Spidermonkey or a similar js binary. I\'ve tri
Fixed it. You need the 'autoconf2.13' package. Install it with apt-get. Go to the SpiderMonkey source code page on Mozilla. Find the hg repository (linked below) and download a snapshot of the Mozilla tree. Don't clone it, just get the archive as .tar.gz or .tar.bz2 from the top bar.
http://hg.mozilla.org/index.cgi/mozilla-central/file/tip
Unzip the archive and cd into the root directory.
$ cd js/src
$ autoconf2.13
$ ./configure
$ make
This should make a binary called js. For some reason, when I ran make install, it did not copy js into /bin/. I just symlinked /bin/js to point to ~/.../mozilla/js/src/js. Lint scripts work now and I don't have to start a build to fix lint errors anymore :P
Source:
https://developer.mozilla.org/en/SpiderMonkey_Build_Documentation
Note: the above link calls for the command autoconf-2.13
. I think this is a typo; you want to use autoconf2.13
as I wrote in the code.
Also, (via #2: spidermonkey-bin not availble in Ubuntu Lucid - Issues - hallettj/jslint.vim - GitHub), can use PPA for Launchpad Engineering : “Canonical Launchpad Engineering” team:
sudo add-apt-repository ppa:launchpad/ppa
sudo apt-get update
sudo apt-get install spidermonkey-bin
apt-cache show spidermonkey-bin
sudo apt-get install spidermonkey-bin # also installs extra: libmozjs2d
# .. and then:
$ js --help
JavaScript-C 1.8.0 pre-release 1 2007-10-03
usage: js [-zKPswWxCij] [-t timeoutSeconds] [-c stackchunksize] [-o option] [-v version] [-f scriptfile] [-e script] [-S maxstacksize] [scriptfile] [scriptarg...]
$ js
js> var f = function(){ print("the answer is " + 42); };
js> f();
the answer is 42
js> ^C
$
Install the package libmozjs-24-bin
. It contains the Spidermonkey JavaScript shell binary /usr/bin/js24
which you can the be installed as an alternative for the command js
.
sudo apt-get install libmozjs-24-bin
sudo update-alternatives --install /usr/bin/js js /usr/bin/js24 10
You can build from source, but spider monkey is still available on ubuntu, it's just been renamed to "libmozjs". Install "libmozjs-24-bin" and then either refer to it as "js24" or symlink /usr/bin/js24 to "js", like so:
sudo apt-get install libmozjs-24-bin; sudo ln -sf /usr/bin/js24 /usr/bin/js
update:
looks like spidermonkey-bin is no longer available through the launchpad ppa
plus the v8jslint repo was down when I tried to clone it.