8

My system node.js version is v0.6.1 but the current stable version is v0.6.7. My system CoffeeScript version is v1.1.2 but the current stable version is v1.2.0

How could I update the node.js and CoffeeScript via terminal on mac( using mac )? I am pretty good with command line but I do need some help get started to update those applications. Thank you very much for helps.

MMA
  • 525
  • 2
  • 10
  • 19

3 Answers3

13

I'm a fan of Homebrew. Once you have it installed, you can just do

brew install node

then install npm with

curl http://npmjs.org/install.sh | sh

then use it to install CoffeeScript with

npm install -g coffee-script

If you don't have Homebrew or don't want to bother with it, replace the first step with going to http://nodejs.org/, clicking "Download," and running the latest installer for OS X. No command line wizardry required.

Update: Since this answer was posted, several things have changed. One is that Homebrew includes npm, so you don't need to install it separately (and if you do, you need to use https://). Another is that I would recommend using nvm to install Node rather than Homebrew, since you'll likely want to use different Node versions for different projects at some point and swapping out brew versions is no fun.

iconoclast
  • 21,213
  • 15
  • 102
  • 138
Trevor Burnham
  • 76,828
  • 33
  • 160
  • 196
  • 2
    Try 1: npm update -g coffee-script # error, failed Try 2: npm install -g coffee-script. # It works. NPM get the latest coffee script 1.2.0 and put it in the node v0.6.7 related folder. but I tried to use "coffee --version". It still shows the old version number 1.1.2. Where did I do wrong? Is there a coffee package that I could select coffee version to use? – MMA Jan 10 '12 at 22:21
  • You need to either uninstall the old `coffee` or change your `PATH` variable so that the directory containing the new version of `coffee` comes before the directory containing the old version. Look at the ouptut from `npm install -g coffee-script` to find out which directory it's putting the binaries in. If it's `/usr/local/bin`, for instance, add the line `export PATH=/usr/local/bin:$PATH` to your `~/.profile` file and restart your shell (or Terminal). – Trevor Burnham Jan 11 '12 at 00:52
  • Thank you very much. Trevor. That fixes the problem.By the way, I read your coffeescript book. and that is how I started to use CoffeeScript. And now, I am using it on all my dev project. I feel that I could manage my CS very well. Thank you again for pushing the Javascript community forward. – MMA Jan 11 '12 at 04:48
  • 1
    if you get "try running as " related errors, do a "sudo su" and try "npm update -g coffee-script" – Josh Hibschman Mar 06 '12 at 21:14
  • 1
    The node package installed with brew comes with NPM since 0.8.0, therefore `curl http://npmjs.org/install.sh | sh` is no longer necessary. – Rob Feb 11 '13 at 12:40
12

To update only coffee-script:

sudo npm update coffee-script -g

Andrzej Karpuszonak
  • 8,896
  • 2
  • 38
  • 50
8

The easiest way to upgrade your Node.js version is to use a version manager such as NVM. It will also keep your old version if you'd like, along with stuff you've installed for it.

Once you upgrade you Node version, you can install CoffeeScript via NPM.

alessioalex
  • 62,577
  • 16
  • 155
  • 122
  • 1
    Step 1: nvm install v0.6.7. # It is super easy to do. I love it. – MMA Jan 10 '12 at 22:14
  • Just as an update, nvm has been my go-to for node version management for a while. Super easy to roll back to a specific version of node, easy to install, easy to update. Way easier than dicking with manually installing node. It's unfortunate you have to have node installed already to install nvm! – AlbertEngelB Feb 25 '13 at 17:49
  • You don't have to have Node previously installed to install nvm, why did you think that? – alessioalex Feb 26 '13 at 19:42