Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade Node.js to the latest version on Mac OS

Currently I am using Node.js v0.6.16 on Mac OS X 10.7.4. Now I want to upgrade it to the latest Node.js v0.8.1. But after downloading and installing the latest package file from nodejs.org, I found that system is still using v0.6.16 instead of v0.8.1 when I typed "node -v" in a terminal. Is there any step that I have missed? Or, should I thoroughly uninstall the old version before installing the latest one?

BTW, I know that nvm can help to manage the nodejs package

https://github.com/creationix/nvm/

Is there any way to upgrade the Node.js without using it?

I have googled this problem, but it seems to me that there is no very clear answer to this question for the latest Node.js.

like image 298
afterglowlee Avatar asked Jul 01 '12 18:07

afterglowlee


People also ask

How do I upgrade Nodejs to a specific version Mac?

node -v. If you want to switch to the different version of Node, just type n in the terminal and you should see the Node versions listed. Use arrow keys to choose the version and press enter.


2 Answers

Here's how I successfully upgraded from v0.8.18 to v0.10.20 without any other requirements like brew etc, (type these commands in the terminal):

  1. sudo npm cache clean -f (force) clear you npm cache
  2. sudo npm install -g n install n (this might take a while)
  3. sudo n stable upgrade to the current stable version

Note that sudo might prompt your password.

Additional note regarding step 3: stable can be exchanged for latest, lts (long term support) or any specific version number such as 0.10.20.

If the version number doesn't show up when typing node -v, you might have to reboot.

These instructions are found here as well: davidwalsh.name/upgrade-nodejs
More info about the n package found here: npmjs.com/package/n
More info about Node.js' release schedule: github.com/nodejs/Release

like image 108
Johan Dettmar Avatar answered Oct 14 '22 21:10

Johan Dettmar


If you initially installed Node.js with Homebrew, run:

brew update brew upgrade node npm install -g npm 

Or as a one-liner:

brew update && brew upgrade node && npm install -g npm 

A convenient way to change versions is to use nvm:

brew install nvm 

To install the latest version of Node.js with nvm:

nvm install node 

If you installed via a package, then download the latest version from nodejs.org. See Installing Node.js and updating npm.

like image 31
wprl Avatar answered Oct 14 '22 22:10

wprl