24
$: which node
$: node
-bash: node: command not found
$: brew install node
Error: node-0.6.18 already installed
$: brew doctor
Error: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built.

node

$: brew link node
Error: No such file or directory - /usr/local/Cellar/node/0.6.5
$: brew uninstall node
Error: No such file or directory - /usr/local/Cellar/node/0.6.5
$: brew install node
Error: node-0.6.18 already installed

How do I get my node back on track??

Nat Ritmeyer
  • 5,634
  • 8
  • 45
  • 58
Jordan Warbelow-Feldstein
  • 10,510
  • 12
  • 48
  • 79
  • What does `brew doctor` says? If nothig helpful, you should consider [sending bug report](https://github.com/mxcl/homebrew/wiki/Reporting-Bugs). – Aleksei Zabrodskii Jun 03 '12 at 18:41
  • Error: You have unlinked kegs in your Cellar Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. geos node postgis proj – Jordan Warbelow-Feldstein Jun 03 '12 at 20:30
  • For anyone else experiencing this problem, I think this is worth looking at too: [Error: The 'brew link' step did not complete successfully](http://stackoverflow.com/q/12607155/320399) – blong Feb 26 '13 at 19:07

7 Answers7

55

I was able to relink the correct version of node by running:

brew cleanup
brew link node
brew uninstall node
brew install node
Jordan Warbelow-Feldstein
  • 10,510
  • 12
  • 48
  • 79
7

I was getting:

$ brew link node
Error: No such keg: /usr/local/Cellar/node
$ brew link node@8
Warning: node@8 is keg-only and must be linked with --force

That command helped to get everything working again:

brew link --overwrite --force node@8
Adam Chwedyk
  • 418
  • 4
  • 8
  • Thanks! I could solve a similar unlink error for gcc ```% brew unlink gcc``` ```Error: No such keg: /usr/local/Cellar/gcc``` by using ```% brew unlink gcc@12``` – Devharsh Trivedi Aug 08 '22 at 20:16
0

To force the link and overwrite all conflicting files:

brew link --overwrite node
Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
0

I personally had to work some sudo chmod magic for node files that were not writable. Brew didn't take care of them by default even after --force was enabled.

L_Sonic
  • 594
  • 6
  • 22
0

echo 'export PATH="/usr/local/opt/node@12/bin:$PATH"' >> ~/.zshrc

  • Hi, welcome to StackOverflow! Could you explain what this code does and why it is the answer to the question? – Tvde1 May 07 '21 at 08:04
  • when you do the 'brew link node ' commande you have to tap this command before to tell him where the node path is ! – Fares ATOUI May 10 '21 at 13:06
0

I puzzled over this for a long time. Nothing worked. I'm using macOS.

In a terminal, execute the following command to get nvm setup with appropriate node.js settings (for further details on what the script does read this https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh):

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh | zsh

Restart your terminal and run the following:

nvm -v You should see a version.

Now let's install node:

nvm install 14.15 When the installation is finished, run:

node -v

You should be good to go.

0

I had the same problem with ruby. I wanted to uninstall it. Here is the fix that worked for me

brew install ruby

Then

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc

Then When I tried uninstall it worked.

brew uninstall ruby

So you can do the same by replacing ruby with node. Then install it again and it will be fixed.

Khaled Annajar
  • 241
  • 3
  • 5