0

I installed node.js on my Mac and I can find the files under /usr/local/bin. But when I try to use the command "node" in the terminal, it says "-bash: node: command not found"

$ echo $PATH

Returns:

./usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home//bin

/usr/local/bin is under the path, and there is a dot in front of it. I guess the dot has something to do with that the command is not found.

What does the dot exactly mean? And what can I do to make the command work in the terminal?

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
vingin
  • 11
  • 1
  • Might already have answer in one of those: https://stackoverflow.com/questions/13593902/node-command-not-found, https://stackoverflow.com/questions/18130164/nodejs-vs-node-on-ubuntu-12-04, https://stackoverflow.com/questions/30467281/mac-bash-node-command-not-found – Shadow The GPT Wizard Aug 25 '17 at 22:25
  • The dot is definitely wrong. Smells like one of your startup files modified `$PATH` incorrectly. And before you ask, "." should *never* be an entry in `$PATH`. – Ignacio Vazquez-Abrams Aug 25 '17 at 22:28
  • *How* did you install node.js? – rckrd Aug 25 '17 at 22:32
  • `.` is your current directory. – stark Aug 26 '17 at 03:13
  • `./usr/local/bin` will make it look for a `usr/local/bin` subdirectory *under your current working directory*, which normally won't exist. Also, that `//` bit near the end looks weird -- double slashes are technically ok, but don't do anything useful, and therefore are probably a mistake of some sort. So there's something weird in one of your shell init scripts, but exactly which one (and what needs to be done to fix it) will require more investigation. – Gordon Davisson Aug 26 '17 at 06:03
  • @GordonDavisson Can you teach me how to find the problem?:-) I have been struggling with it for a while. It is the same problem when I install Atom, the command is not found either. – vingin Aug 26 '17 at 07:31
  • @rckrd I downloaded it from the webside and followed the instruction, so it should be any problem with the installation. – vingin Aug 26 '17 at 09:39
  • @vingin You'll need to look through your shell init files (~/.bash_profile, ~/.bash_login, or ~/.profile, and maybe ~/.bashrc) for lines that modify `PATH`. Unfortunately, the bad settings might also be in some other script that one of those runs with the `source` or `.` commands. Finding the problem should be fairly simple; figuring out how to fix it (i.e. how to make it do what it's supposed to) may be a lot harder. – Gordon Davisson Aug 28 '17 at 04:51

0 Answers0