Opinionated Programmer - Jo Liss's musings on enlightened software development.

Installing CoffeeScript on Ubuntu or Debian

Last updated: Dec 20, 2011

Four ways to install CoffeeScript, from best to worst:

1. npm on Ubuntu 11.10 Oneiric or Debian sid

The latest coffee-script packages in Ubuntu and Debian are always a bit outdated (see the CoffeeScript change log). CoffeeScript still changes a lot, so I recommend using npm, like so:

1
2
sudo apt-get install nodejs npm &&
sudo npm install coffee-script

(You can ignore npm’s warning about sudo being bad.)

And that’s all. :-) Run coffee for an interactive shell (REPL), and coffee --help for help.

2. npm on older Ubuntus

On older Ubuntus, we need to use a PPA to pull in a recent enough Node.js (>= 0.4) and npm:

1
2
3
4
5
6
7
sudo apt-get install python-software-properties &&
sudo add-apt-repository ppa:chris-lea/node.js &&
sudo apt-get update &&
sudo apt-get install nodejs npm &&
npm config set prefix /usr/local &&  # defaults to /usr since 1.0 (weird)
sudo npm install coffee-script -g &&  # -g => globally (/usr/local)
coffee --version

I have tested this on 11.04 Natty, though it should work on 10.04 and 10.10 as well.

3. Packages

These are slightly outdated, but you can use them if you absolutely hate npm:

4. Manually

If all else fails:

  1. Head to the Node.js download page and download the latest stable version. Assuming you are installing version 0.6.6, you can copy and paste this whole block into your shell:

    1
    2
    3
    4
    5
    
    wget http://nodejs.org/dist/v0.6.6/node-v0.6.6.tar.gz &&
    tar xzvf node-v0.6.6.tar.gz && cd node-v0.6.6 &&
    sudo apt-get install make g++ libssl-dev &&  # dependencies
    ./configure && make && ./node --version &&
    sudo make install  # install into /usr/local
  2. Now let’s install CoffeeScript: Head to the CoffeeScript home page for the latest version. Assuming it’s 1.2.0, here’s a block to copy and paste:

    1
    2
    3
    4
    5
    
    wget -O- --no-check-certificate \
        https://github.com/jashkenas/coffee-script/tarball/1.2.0 | tar xz &&
    cd jashkenas-coffee-script-*/ &&
    bin/cake test && bin/coffee --version &&  # test; no need to build
    sudo bin/cake install  # install to /usr/local

I have tested this on 11.04 Natty. If Node 0.6 doesn’t work for you, try http://nodejs.org/dist/node-v0.4.12.tar.gz.

Happy brewing!