How to install latest version of Node using Brew

The latest version of NodeJs right now is 0.4.1

The command brew install node right now, installs 0.2.6 - which is not ideal. I would like 0.4.1

I've looked at this list of commands for brew and tried brew install --HEAD node

But that installs node 0.5-pre.

Why isn't brew installing the right version and how can I force it to get the right one?

At this stage, it looks like it would actually be easier just to download the src and install it manually. But I would like to know what's going on with Brew.


Solution 1:

Run commands below, in this order:

brew update
brew doctor
brew upgrade node

Now you have installed updated version of node, and it's probably not linked. If it's not, then just type: brew link node or brew link --overwrite node

Solution 2:

After installation/upgrading node via brew I ran into this issue exactly: the node command worked but not the npm command.

I used these commands to fix it.

brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) /usr/local
brew link --overwrite node
brew postinstall node

I pieced together this solution after trial and error using...

  • a github thread: https://github.com/npm/npm/issues/3125

  • this site: http://developpeers.com/blogs/fix-for-homebrew-permission-denied-issues

Solution 3:

Have you run brew update first? If you don't do that, Homebrew can't update its formulas, and if it doesn't update its formulas it doesn't know how to install the latest versions of software.