MacOS – How to downgrade node or install a specific previous version using homebrew

homebrewmacos

I'm using brew. I have node installed, using brew. I want to use an earlier version of node.

Online, I find instructions such as, for example:

cd /usr/local/Library/Formula
brew remove node --force
brew versions node
git checkout 83988e4 /usr/local/Library/Formula/node.rb
brew install node

The problem I have with this is that brew doesn't seem to have a versions subcommand:

$ brew versions node
Error: Unknown command: versions
$ brew --version
0.9.5

I'm new to brew. Do I need to enable the versions subcommand somehow? Should I use a different subcommand instead? Is there a completely different method I should try?

I'm running OS X Yosemite (10.10.1); brew 0.9.5.

Best Answer

These days if you want to install a different version of node you do it this way:

First search for your desired package:

brew search node

This might give you the follow results:

heroku/brew/heroku-node ✔
llnode
node@10
nodebrew
leafnode
node ✔
node@8
....

And then install the desired version:

brew install node@8

Also remember that you can install more than 1 node package at the same time, but you cannot have them available at the same time. So if you have the latest/generic node package already installed you need to unlink it first:

brew unlink node

And then you can link a different version:

brew link node@8

For some older node versions (which are keg-only), it might be required to link them with the --force and --overwrite options:

brew link --force --overwrite node@8