Search code examples
javascriptnode.jsterminalhomebrewnvm

Want to switch between node versions, but unable to install node 8 through homebrew (currently on node 13)


I'm trying to install node version 8 (node@8) on my mac through homebrew.

My current version of node is 13.6.0, which I downloaded through homebrew, and I'd like to be able to switch between node 8 and node 13 versions for different projects.

However, when I try to download node@8 using

brew info node@8

I get the following error

Error: No available formula with the name "node@8"

To diagnose why, I ran

brew search node

And I was shown the following

libbitcoin-node node ✔ node-sass node@12 nodebrew nodenv llnode node-build node@10 node_exporter nodeenv

It looks like my current version of node can't even search for @8. That being the case, I'd like to know two things.

  1. What is the best homebrew (or otherwise) command sequence to get node8 on my machine, given my version of homebrew can't find node8 using brew search?
  2. What sequence should I use to switch between the node 8 and node 13 versions on a project by project basis?

Solution

  • Use NVM - Node Version Manager

    https://github.com/nvm-sh/nvm
    

    You can set your default Node version and install any other versions you like.

    Switching off your default version is as easy as nvm use 10.12.0 or whatever version you wish.