Best way to get spidermonkey js on Ubuntu?

前端 未结 5 1096
小鲜肉
小鲜肉 2020-12-30 04:15

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

相关标签:
5条回答
  • 2020-12-30 04:20

    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.

    0 讨论(0)
  • 2020-12-30 04:30

    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
    $
    
    0 讨论(0)
  • 2020-12-30 04:35

    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
    
    0 讨论(0)
  • 2020-12-30 04:36

    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
    
    0 讨论(0)
  • 2020-12-30 04:43

    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.

    0 讨论(0)
提交回复
热议问题