afterglowlee afterglowlee - 6 months ago 26
Node.js Question

Upgrade NodeJS to the latest version on Mac os

I am currently using NodeJS v0.6.16 on mac os x 10.7.4. Now I want to upgrade it to the latest NodeJS v0.8.1. But after downloading and installing the latest pkg file from nodejs.org, I find the 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 means to upgrade the nodejs 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 NodeJS. Many thanks.

Answer

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

brew update
brew upgrade node
npm install -g npm

If you installed via a package, then download the latest version from nodejs.org. This is now the recommended way to install node (>4.0)

See Installing Node.js and updating npm.

Note: If you have npm --version >= 2.7.1, you can replace install (above) with update.