How to install latest version of Node using Brew

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.


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


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

Tags:

Macos

Homebrew