gpt4 book ai didi

node.js - Github Action err : bash: line 3: npm: command not found

转载 作者:行者123 更新时间:2023-12-03 12:17:58 27 4
gpt4 key购买 nike

我正在尝试通过ssh从github将nodejs应用程序部署到远程ubuntu服务器。这是我的main.yml:

name: Node Github CI

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Node Js
uses: actions/setup-node@v1

- name: SSH and deploy node app
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SERVER_KEY }}
script: |
service myservice stop
cd leancrm-backend
git pull git://myuser@github.com/mycmp/myapp-backend.git master
npm install
service myservice start
运行此命令时,出现以下错误:
======CMD======
service myservice stop
cd myapp-backend
git pull git://myuser@github.com/mycmp/myapp-backend.git master
npm install
service myservice start

======END======
err: fatal: Unable to look up myuser@github.com (port 9418) (Name or service not known)
err: bash: line 3: npm: command not found
==============================================
截屏:
enter image description here

最佳答案

由于您已连接到服务器,所以我假设您已经在该仓库中了,因此您只需要执行git pull。
另外,您应该在脚本的开头添加以下行:

export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
我的yml文件在末尾看起来像这样:
script: |
git pull
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
npm install
npm run start_server

关于node.js - Github Action err : bash: line 3: npm: command not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62863080/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com