0

After I have installed node, it works. I quit terminal and then I can't use node command in bash. Would anyone know why this is happening? Its rather infuriating. I think it may be something to do with the $PATH variable not being initialised in the right order or not at all.

I followed the 1st option https://gist.github.com/isaacs/579814

m33bo
  • 1,334
  • 1
  • 17
  • 34
  • What OS are you using? – David Weldon Dec 05 '13 at 17:35
  • osx, 10.9, It works when I go to `~/local/bin` then `./node`, just can't get bash to see the command `node` or `npm` – m33bo Dec 05 '13 at 17:37
  • What happens if you put the `$PATH` line in your `~/.profile` and then open a new terminal? – David Weldon Dec 05 '13 at 17:39
  • I put in `export PATH=$HOME/local/bin:$PATH` but no luck – m33bo Dec 05 '13 at 17:44
  • `echo $PATH && source ~/.profile && echo $PATH`. Is there a difference between the two lines printed? – David Weldon Dec 05 '13 at 17:50
  • If I run the command, node works straight out of bash, otherwise it doesn't. How can I merge the 2? – m33bo Dec 05 '13 at 17:59
  • 1
    So your problem isn't the text it's that your files are not being sourced when you open a new terminal. I just tried this on a friend's 10.8 and found that stuff in `~.bashrc` gets loaded fine but `~/.profile` doesn't. Which is a complete contradiction of [this](http://stackoverflow.com/questions/7780030/how-to-fix-terminal-not-loading-bashrc-on-os-x-lion). Maybe [this](http://stackoverflow.com/questions/7780030/how-to-fix-terminal-not-loading-bashrc-on-os-x-lion) would help? Not being a mac person I don't know how to help more. – David Weldon Dec 05 '13 at 18:11
  • Add `export PATH=$HOME/local/bin:$PATH` in `~/.bash_profile` and `source ~/.bash_profile` or exit and open new terminal. Create `~/.bash_profile` it isn't available already. – vmx Dec 05 '13 at 18:18
  • Sorted it from @DavidWeldon s comment, I changed around the info in the files. Thanks man, really appreciate it. – m33bo Dec 05 '13 at 18:20

1 Answers1

1

Thanks to @DavidWeldon and @Vinayak Mishra

Add export PATH=$HOME/local/bin:$PATH in ~/.bash_profile and source ~/.bash_profile or exit and open new terminal. Create ~/.bash_profile it isn't available already.

If there is a problem with the $PATH, you can check it with: echo $PATH && source ~/.profile && echo $PATH

If there are difference, files are not being called in the right order. Take a look at this.

Community
  • 1
  • 1
m33bo
  • 1,334
  • 1
  • 17
  • 34