每当codeship将我的代码部署到DigitalOcean上时,我都会尝试自动运行“npm install”和“pm2 restart all”。
这是自定义脚本:
rsync -avz -e "ssh" ~/clone/ root@IP:/opt/projectname
ssh root@IP 'cd /opt/projectname/; npm install; pm2 restart all'
rsync有效。代码将部署到DigitalOcean上的正确文件夹中。
但是,第二行失败了。错误:
bash: npm: command not found
bash: pm2: command not found
为什么?