Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install latest version of Node using Brew

Tags:

macos

homebrew

People also ask

Can I install Node with homebrew?

Use Homebrew to install Node. js on MacOS. Homebrew is a better way to manage various packages on your Mac.


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


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


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.


Sometimes brew update fails on me because one package doesn't download properly. So you can just upgrade a specific library like this:

brew upgrade node

https://gist.github.com/3005832


Also, try to deactivate the current node version after installing a new node version. It helps me.

nvm deactivate

This is removed /Users/user_name/.nvm/*/bin from $PATH

And after that node was updated

node --version
v10.9.0

I had to do brew link --overwrite node after brew install node to update from 0.4 to 0.8.18


If you have installed current node via Homebrew, just use these commands.

brew update
brew upgrade node

Check node version by

node -v