How to update node.js and CoffeeScript version via terminal on mac?
Solution 1
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.
Solution 2
To update only coffee-script:
sudo npm update coffee-script -g
Solution 3
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.
MMA
Web Developer. Javascript developer. CoffeeScript user, and Node.js learner.
Updated on July 27, 2022Comments
-
MMA almost 2 years
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 over 12 yearsStep 1: nvm install v0.6.7. # It is super easy to do. I love it.
-
MMA over 12 yearsTry 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?
-
Trevor Burnham over 12 yearsYou need to either uninstall the old
coffee
or change yourPATH
variable so that the directory containing the new version ofcoffee
comes before the directory containing the old version. Look at the ouptut fromnpm 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 lineexport PATH=/usr/local/bin:$PATH
to your~/.profile
file and restart your shell (or Terminal). -
MMA over 12 yearsThank 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.
-
Josh Hibschman about 12 yearsif you get "try running as " related errors, do a "sudo su" and try "npm update -g coffee-script"
-
Rob over 11 yearsThe node package installed with brew comes with NPM since 0.8.0, therefore
curl http://npmjs.org/install.sh | sh
is no longer necessary. -
AlbertEngelB about 11 yearsJust 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!
-
alessioalex about 11 yearsYou don't have to have Node previously installed to install nvm, why did you think that?
-
Andrei Karpushonak almost 11 yearsActually, sudo is required on OS X, please see here: github.com/isaacs/npm/issues/3139
-
froginvasion over 10 yearswell, that depends, since coffee-script wants to put a symlink in /usr/bin , it could be that it fails to install globally? I'm not sure.