'How to link an old version of node in mac using homebrew

I am trying to link to an older version of node using homebrew in my mac (because netlify doesn't work with v17 - which is my default).

When I search which versions of node I have installed, I can see that both 16 and 14 are available.

brew search node ==> Formulae libbitcoin-node node ✔ node-sass node@12 node@16 nodebrew nodenv llnode node-build node@10 node@14 node_exporter nodeenv ode

I expect to be able to run brew unlink node (which works fine) and then

brew link node@16 or brew link node@14, but in both cases, I get an error that says:

Error: No such keg: /usr/local/Cellar/node@16

How can I ask homebrew to use an old version of node?



Solution 1:[1]

This is what I did:

  • brew install node@16
  • export PATH="/opt/homebrew/opt/node@16/bin:$PATH" (you need to put into ~/.bash_profile or ~/.zprofile to persist the change)

And then I can see the node points to node@@16

$ which node
/opt/homebrew/opt/node@16/bin/node

$ node --version
v16.14.2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 chenrui