3

I installed node through homebrew 8 months ago.

  • I just tried to upgrade node through homebrew and it didnt work.

  • Instead, I got some message that encouraged me to run a line of code to fix it (I forget the code) but I think it broke my npm instead because my npm stopped working and I now get the error: zsh: command not found: npm when running any npm command.

  • I proceeded to completely uninstall node with this guide

  • I then began to reinstall node through homebrew with this guide

  • When I ran brew doctor I found that I have a lot of broken symlinks, including many npm files such as:

    /usr/local/share/man/man1/npm-README.1

    /usr/local/share/man/man1/npm-access.1

    /usr/local/share/man/man1/npm-adduser.1

    (along with about 60 other npm files and other fils including):

    /usr/local/bin/grunt

    /usr/local/bin/gulp

Where do I go from here? I simply want to reinstall node and npm through homebrew so that they work properly. Should I remove the broken symlinks with brew prune: or will that cause more problems for me? Thank you.

Community
  • 1
  • 1
georgej
  • 2,401
  • 4
  • 17
  • 43

2 Answers2

5

brew prune is meant for this. You can also dry run it to see what will be removed with the --dry-run flag.

prune [--dry-run]
              Remove dead symlinks from the Homebrew prefix. This is generally not needed, but can be useful when doing DIY installations. Also remove broken  app
              symlinks from /Applications and ~/Applications that were previously created by brew linkapps.

              If --dry-run or -n is passed, show what would be removed, but do not actually remove anything.
vidit
  • 6,007
  • 3
  • 28
  • 46
0

If you end up here because on the other way around you have a package installed with brew whose link seemed to disappear, relink like this:

brew unlink [package] && brew link [package]
Crazy Barney
  • 919
  • 1
  • 12
  • 19