2

I was having an issue pushing a git commit, so I ran sudo ln -sf /usr/bin/nodejs /usr/local/bin/node now when running node -v or nodejs -v terminal tells me -bash: node: command not found.

How can I 'undo' the sudo ln -sf

Simon Cooper
  • 1,574
  • 4
  • 24
  • 53
  • 2
    You can't simple undo it, you overwrote your `node` binary. Reinstall `node` using your system's package manager. – Arkadiusz Drabczyk Dec 27 '17 at 20:57
  • @ArkadiuszDrabczyk: The system's package manager probably wouldn't install `node` in `/usr/local/bin/`. (It's `/usr/bin/node` on my Ubuntu system.) The `sudo ln` command might have clobbered `/usr/local/bin/node`, or there might have been nothing there in the first place. Simon, what does `type -a node` tell you? – Keith Thompson Dec 27 '17 at 21:05
  • @KeithThompson `-bash: type: node: not found` – Simon Cooper Dec 27 '17 at 21:47
  • Does `/usr/bin/nodejs` exist? Does `/usr/bin/node` exist? – Keith Thompson Dec 27 '17 at 23:28
  • @KeithThompson sorry for slow reply, Christmas happened! `Simons-MBP:gourmet_coffee Simon$ type -a node node is /usr/local/bin/node node is /usr/local/bin/node` I still have the issue. And yes it does print the two lines of node is /usr/local/bin/node – Simon Cooper Jan 15 '18 at 11:59
  • No problem on the slow reply, but you didn't actually answer my questions. – Keith Thompson Jan 15 '18 at 19:15

1 Answers1

2

Try this:

sudo unlink /usr/bin/nodejs
brunomarks7
  • 151
  • 1
  • 4
  • 3
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – mufazmi May 18 '21 at 19:52