Best way to get spidermonkey js on Ubuntu?

ovrkenthousand picture ovrkenthousand · Jul 11, 2011 · Viewed 23.3k times · Source

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 tried compiling Spidermonkey from source and gotten stuck in dependency hell. I tried installing the rhino package from the ubuntu repositories, and that turned out to be slow and broken. This morning, I successfully compiled Google's V8 engine and built v8jslint following the instructions here:

http://blog.stevenreid.co.uk/2011/06/27/jslint-command-line-tool-powered-by-v8/

v8jslint works, but will only lint one file at a time. For instance,

$ v8jslint foo/*.js

if I have a.js, b.js and c.js under foo, v8jslint will only lint a.js. Easy fix: I could write a bash script for this. A bigger problem is that v8jslint is not compatible with the Spidermonkey jslint on our build server. Has anyone had any success building Spidermonkey on a recent version of Ubuntu, or know a good workaround?

Answer

easel picture easel · Feb 18, 2015

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