Node already installed, it's just not linked

63,408

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.

  1. sudo chmod 776 /usr/local/lib
  2. brew link --overwrite node

    Outputs: Linking /usr/local/Cellar/node/9.6.1... 49 symlinks created

  3. 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

Share:
63,408
Ela
Author by

Ela

A big travel fun who loves problem solving. Currently working on making things very pretty using AngularJS but a big fun of Machine Learning where I can put my maths skills into practice.

Updated on July 08, 2022

Comments

  • Ela
    Ela almost 2 years

    I tried to fix the error where you have to use sudo when running npm. I blindly followed a link to uninstall node, the code was from this gist

    After running the command and I tried to install it back with brew: brew install node. Which gave me the following error:

    Error: The `brew link` step did not complete successfully
    The formula built, but is not symlinked into /usr/local
    Could not symlink share/doc/node/gdbinit
    /usr/local/share/doc/node is not writable.
    
    You can try again using:
      brew link node
    

    Trying to run brew link node, I got:

    Linking /usr/local/Cellar/node/5.4.0... 
    Error: Could not symlink share/systemtap/tapset/node.stp
    /usr/local/share/systemtap/tapset is not writable.
    

    Then when I write brew install npm, I get:

    Warning: node-5.4.0 already installed, it's just not linked
    

    When I write npm -v I get:

    env: node: No such file or directory
    

    Any ideas on how to solve this?