I installed PM2 globally on Debian 10 (buster) using the following approach.
npm config set prefix ~/.local
echo 'export PATH=~/.local/bin/:$PATH' >> ~/.bashrc
source ~/.bashrc
npm -g install pm2
When I run ssh user@host pm2 ls
, I get pm2: command not found
.
It is my understanding that SSH commands run in non-interactive shells that do not source ~/.bashrc
. Is this assumption correct?
Is there a way to work around this limitation without using an absolute path for pm2
?
The above proof of concept is simplified. I am actually running a remote script that calls other scripts. Using an absolute path would make the scripts deployment-specific which I am trying to avoid.