admin管理员组

文章数量:1122846

I install fnm inside my EC2 instance and uninstalled the old node that was installed before without any node package manager.

The server run correctly with new versions of node and npm.

Before the usage of fnm, the Yaml File was:

name: Deploy Node.js Application to EC2

on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: Deploying Node.js Application
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up SSH key
        env:
          PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
        run: |
          echo "$PRIVATE_KEY" > private_key
          chmod 600 private_key

      - name: Deploy to EC2
        env:
          HOSTNAME: ${{ secrets.hostName}}
          USER_NAME: ubuntu
        run: |
          ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} "cd ~/My_project && git pull origin main && npm install && npm run server"

Now the action failed always with the error bash: line 18: npm: command not found

I tried many ways to update the path to use the correct path to fnm but I got lost (I couldn't find any docs for that , i tried implement as i saw for nvm but it didnt works)

本文标签: nodejsGithub action to deploy node js using fnmStack Overflow