I'm trying to run a simple command from an init.d script and I'm troubleshooting why the command doesn't work when I run it from my init.d script but works when I run it as my user.
Can someone explain why when I run
nvm --version as my logged in user it shows a value, but when I
su to my user it does not know what
nvm is? This is ultimately the root cause of my init.d script not working I believe.
$ whoami someuser someuser@node-server1:/var/www/dev$ nvm --version 0.18.0 someuser@node-server1:/var/www/dev$ su - someuser -c "nvm --version" Password: -su: nvm: command not found
I noticed this in my .bashrc:
export NVM_DIR="/home/someuser/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
Do I somehow need to run this as a command in my init.d script or when I
su to a user?