如何在Github操作中指定节点的路径? [英] How to specify node's path in Github action?
本文介绍了如何在Github操作中指定节点的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Github的node.js工作流在我的存储库上自动测试。但是,我遇到了困难,因为节点设置在子目录中,而不是我的存储库的根目录中。我一直在寻找一种方法来指定要在其中运行NPM命令的目录,但没有找到任何答案。
以下是工作流代码:
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
with:
path: backend_app
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: cd backend_app
- run: npm ci
- run: npm run build --if-present
- run: npm test
以下是由操作Run生成的错误:
Run npm ci
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/work/directory_name/directory_name/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/work/directory_name/directory_name/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-06-16T03_36_41_777Z-debug.log
Error: Process completed with exit code 254.
推荐答案
此问题似乎已得到答复。
How do I run my CI steps in a specific folder in github action
这篇关于如何在Github操作中指定节点的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文