Tried to update this topic (SSH command works manually but not in SSH node - #2 by Jon) but I was not able to update a closed topic, so writing here in case it helps someone else.
n8n ssh node uses non-interactive shell - export variables in command section
Trying to run following playwright command on remote machine using ssh n8n node:
npx playwright test --project=chromium -g “extract_prestashop_data”
When used within ssh n8n node, I get:
bash: line 1: npx: command not found
This command works if I manually remote onto machine execute command i.e.
ssh whitbym@remote_machine
From: ssh command and non-interactive, non-login shell - Unix & Linux Stack Exchange
Non-interactive login shell
general format: ssh example.com <my-script-which-is-stored-locally
This seems to be how the n8n ssh node works, and when I put my playwright command in the local script, I get the same error as the n8n ssh node.
From this link:
I can see the following in my ~/.bashrc file:
export NVM_DIR=“$HOME/.nvm”
[ -s “$NVM_DIR/nvm.sh” ] && . “$NVM_DIR/nvm.sh” # This loads nvm
[ -s “$NVM_DIR/bash_completion” ] && . “$NVM_DIR/bash_completion” # This loads nvm bash_completion
And I also tried it in the local script to test it out using non-interactive login shell.
So in the n8n ssh node command section, I put the exports plus my playwright command as below:
export NVM_DIR=“$HOME/.nvm”
[ -s “$NVM_DIR/nvm.sh” ] && . “$NVM_DIR/nvm.sh” # This loads nvm
[ -s “$NVM_DIR/bash_completion” ] && . “$NVM_DIR/bash_completion” # This loads nvm bash_completion
npx playwright test --project=chromium -g “extract_prestashop_data”
And hurrah - it all now works !