Downgrade NodeJS with Brew on Mac OS

I recently had to downgrade my nodejs installation to v16.00 because version 18.x introduced some breaking changes to dependencies. Here is how this was done with brew:

  • Current Node version:
node --version
  • Search for the desired NodeJS version:
brew search node@16
  • Unlink the current node version
brew unlink node
  • Install the new version of Node:
brew install node@16
  • Link the node version. Test with the --dry-run flag to get a list of all files which will be deleted:
brew link --overwrite --dry-run node@16
brew link --overwrite node@16