Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pnpm: command not found #157

Closed
Laxy317 opened this issue Aug 6, 2023 · 2 comments
Closed

Pnpm: command not found #157

Laxy317 opened this issue Aug 6, 2023 · 2 comments

Comments

@Laxy317
Copy link

Laxy317 commented Aug 6, 2023

I'm trying to deploy a front-end project to a remote server using Github Action, and I confirme that the remote server has downloaded pnpm.

Github Action:

    - name: Deploy public
      uses: easingthemes/ssh-deploy@v4.1.8
      env:
          IP: ${{ secrets.IP }}
          SSH_PRIVATE_KEY: ${{ env.SERVER_PRIVATE_KEY }}
          SOURCE: "pnpm-lock.yaml" 
          REMOTE_HOST: ${{ env.SERVER_HOST }}
          REMOTE_USER: ${{ env.USER_NAME }}
          TARGET: '/home/ubuntu/test/' 
      with: 
          SCRIPT_AFTER: |
            cd /home/ubuntu/test
            pnpm start
            docker start nginx

Log:

Executing remote script: ssh -i /home/runner/.ssh/deploy_key_***_1691335359810 ***@***
✅ [CMD] Remote script executed. 
 nginx
 bash: line 2: pnpm: command not found

✅ [DONE] 
@Laxy317 Laxy317 closed this as completed Aug 7, 2023
@Palaxx
Copy link

Palaxx commented Oct 9, 2024

Hello @Laxy317 ,
I've the same issue of you but with npm and pm2, could you please share how you fixed it?

My SCRIPT_AFTER is the following:

SCRIPT_AFTER: |
            pwd
            npm ci
            pm2 restart server

and I received

bash: line 2: npm: command not found
bash: line 3: pm2: command not found

Thanks

@Palaxx
Copy link

Palaxx commented Oct 11, 2024

The problem is caused by the library execute the after script using bash -c which by default does not load the user configurations.

I solve thanks to this issue in ssh-action repository executing the following commands:

sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/node" "/usr/local/bin/node"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/npm" "/usr/local/bin/npm"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/pm2" "/usr/local/bin/pm2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants