Homebrew suggests there's always an existing formula for node installed?

I am trying to install node to use with reactjs. I started with node 16 but found it was incompatible with node-sass, so I've downgraded to node 14.

When installing (brew install node@14), it remains keg-only as it says:

node@14 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

Node 16 had been installed with brew install node and uninstalled with brew uninstall node. I've ran brew cleanup, I've uninstalled and reinstalled brew via the official uninstall script. When I run brew info node it says:

node: stable 16.3.0 (bottled), HEAD
Platform built on V8 to build network applications
https://nodejs.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/node.rb
License: MIT
==> Dependencies
Build: pkg-config ✘, [email protected] ✘
Required: brotli ✘, c-ares ✘, icu4c ✔, libuv ✘, nghttp2 ✘, [email protected] ✘
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 345,586 (30 days), 1,126,089 (90 days), 4,391,805 (365 days)
install-on-request: 271,229 (30 days), 880,350 (90 days), 3,293,366 (365 days)
build-error: 0 (30 days)

Which, in my limited understanding, suggests 16 is not installed.

What is causing node to say there's already a formula for node installed and it must keep v14 in keg-only mode? I'm on macos mojave and I don't believe there's any included node that would conflict? Running brew list shows node isn't present.


Updates

I ran brew bundle dump and it gave:

tap "homebrew/bundle"
tap "homebrew/core"
brew "node@14"

... which again, I don't quite understand why installing node@14 ends with a keg-only install because it states that "this is an alternate version of another formula."

The only thing I can think of now is that the other formula is referring to the fact that 14 is not the default release (which is now 16) whether the latest is installed or not?

But this also doesn't make sense to me as I'd imagine a simple y/n warning that a newer release exists would be more beneficial rather than making 14 not work on the command line without manual intervention that I'm hesitant to do.


Running brew doctor states:

Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/more/.
You should download the Command Line Tools for Xcode 11.3.1.


Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

I couldn't see anything noteworthy in the lib folder other than 'node_modules' that I'm unsure of what build it came from. I tried removing it temporarily and reinstalling node@14 but the same problem remains.


brew link node@14

You can have both versions installed and switch with the above (change @14 to @16). Since you initially installed v16, your symlinks are pointing there, so run above to reset the correct v14 you are looking to use.

As suggested above, you can use nvmto manage different node versions, but I personally have found it much easier to use brew link to easily change between versions rather. n is another popular one, but again, my personal choice isbrew. Colleagues prefer n, so take your pick.


You should use nvm to manage multiple node installation.

Install it with:

brew install nvm

Create the nvm directory:

 mkdir ~/.nvm

Install the version you want:

nvm install 14

You can then list your available versions with nvm ls and list all available commands with just nvm.