I m trying to automatically run "npm install" and "pm2 restart all" whenever codeship deployed my codes onto DigitalOcean.
This is the custom script:
rsync -avz -e "ssh" ~/clone/ root@IP:/opt/projectname
ssh root@IP 'cd /opt/projectname/; npm install; pm2 restart all'
The rsync works. Codes will be deployed onto the correct folder on DigitalOcean.
However, the second line fails. Error:
bash: npm: command not found
bash: pm2: command not found
Why?