sudo npm cache clean -f
sudo npm install -g n
sudo n stable/lts
#this will update postgres and dependencies and
#sometimes will be enough. check version after
brew update
brew upgrade node
node --version # outputs: v12.x.x
#not the version i wanted so list packages
nvm ls
#Find the version I want, says N/A: default -> 16.15.1 (-> N/A)
nvm install 16.15.1
node --version # outputs: v16.15.1 !hooray!
brew update
brew upgrade node
// use brew to upgrade node to the latest version
brew update
brew upgrade node
node --version // outputs: v12.x.x
// also you can do it with npn
sudo npm cache clean -f // clean first
sudo npm install -g n // install globally
sudo n stable/lts
// Fix node not found first
sudo chown -R `whoami`:admin /usr/local/include/node
sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
sudo chown -R `whoami`:admin /usr/local/lib/dtrace
brew link --overwrite node
// Then:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable/lts