I am trying to call an installation of node.js on a remote server running Ubuntu via SSH. Node has been installed via nvm.
SSHing in and calling node works just fine:
user@localmachine:~$ ssh user@remoteserver
(Server welcome text)
user@remoteserver:~$ which node
/home/user/.nvm/v0.10.00/bin/node
However if I combine it into one line:
user@localmachine:~$ ssh user@remoteserver "which ls"
/bin/ls
user@localmachine:~$ ssh user@remoteserver "which node"
No sign of node, so I tried sourcing .bashrc and waiting 10 seconds:
user@localmachine:~$ ssh user@remoteserver "source ~/.bashrc; sleep 10; which node"
Only node seems affected by this. One thing I did notice was that if I ssh in and then check which shell I'm in it says -bash whilst if I ssh direct it gives me /bin/bash. I tried running the commands inside a bash login shell:
user@localmachine:~$ ssh user@remoteserver 'bash --login -c "which node"'
Still nothing.
Basically my question is: Why isn't bash finding my node.js installation when I call it non-interactively from SSH?