Node.js not linked error

Execute this list of commands in this particular order:

sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) $(brew --prefix)
brew link --overwrite node
brew postinstall node

After you've run brew upgrade to update node to the latest version, run brew doctor to see what potential problems there are. It might tell you that node is unlinked, in which case, running brew link node will link it. (You might need to first run brew unlink node)


I got the same error today and it told me that Node was not properly linked and there were unexpected header files as well.

When I tried to reinstall node, It told me that it was already installed, just not linked.

Warning: /usr/local/include isn't writable

/usr/local/bin/node already exists. Remove it

Solution

To fix this, I took ownership of it by using:

sudo chown -R `whoami` /usr/local/

Then I force linked all files by using:

brew link --overwrite node

After that I did the post install routine with:

brew postinstall node

Then I checked if node was properly installed with:

node -v

I received output v5.1.0 and It was fixed :). Hope this helps.

This may not be the perfect fix out there since I have started dabbling with node and homebrew just 10 minutes ago but it did the job for me.