Node already installed, it's just not linked
Solution 1:
I managed to fix this by first running sudo chown -R $USER /usr/local
and following it with brew link node
. Now I have node properly installed.
Solution 2:
This solution works! It is a combination of all the combinations.
Fix it using the following code.
sudo chmod 776 /usr/local/lib
-
brew link --overwrite node
Outputs:
Linking /usr/local/Cellar/node/9.6.1... 49 symlinks created
sudo chmod 755 /usr/local/lib
Solution 3:
for OSX High Sierra users:
sudo chown -R $(whoami) $(brew --prefix)/*
brew link --overwrite node
then check node -v and npm -v
Solution 4:
For Mojave || Catalina || Big Sur || Monterey use:
sudo chown -R $(whoami) $(brew --prefix)
brew link --overwrite node
Solution 5:
If you are on High Sierra, then sudo chown -R $USER /usr/local
won't work. Instead use:
sudo chown -R $(whoami) $(brew --prefix)/*
Source: https://github.com/Homebrew/brew/issues/3228#issuecomment-332679274