3

Github action searches for package.json in the project, but in a folder with the same name as the project ('/home/runner/work/javascript-coding-challenges/javascript-coding-challenges/package.json'). I don't have package.json there.

My jest.yaml

name: Run Jest tests
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install modules
      run: npm install
    - name: Run tests
      uses: stefanoeb/jest-action@1.0.3
      with:
        jestArgs: passWithNoTests

Error:

npm WARN saveError ENOENT: no such file or directory, open '/home/runner/work/javascript-coding-challenges/javascript-coding-challenges/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/runner/work/javascript-coding-challenges/javascript-coding-challenges/package.json'
npm WARN javascript-coding-challenges No description
npm WARN javascript-coding-challenges No repository field.
npm WARN javascript-coding-challenges No README data
npm WARN javascript-coding-challenges No license field.

I am not entirely sure how to remedy this. Is it possible to "exit" from the current folder? (like cd ..) This will allow github action to find the correct folder where package.json is located.

I've checked these two answers:

github actions can not find package.json

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'

but both of them are not answering my question (I see in first one changing uses into ./ but I want to use this specific action)

TheTanadu
  • 554
  • 1
  • 7
  • 33
  • `/home/runner/work/javascript-coding-challenges` is where your workflow runs. The `javascript-coding-challenges` below that is where the repository was checked out. So if your repo has a `package.json` checked in, it should indeed be at `/home/runner/work/javascript-coding-challenges/javascript-coding-challenges/package.json`. Why do you think it's a level up? If you run `ls -l` as the first step of your workflow, what do you see? – Edward Thomson Nov 23 '20 at 09:06
  • 3
    @EdwardThomson, I can't even... I solved it. It was so 'stupid and obvious at once' because my package.json went missing and I was 120% sure it was in this PR. But that taught me - actions are looking for a nested 'project name' if there is no package.json and it was not commented on in other problems I found – TheTanadu Nov 23 '20 at 16:37

0 Answers0