20

I am currently working on replacing our Drone CI installation with GitHub Actions.

The Action Workflow I have so far boils down to the following .github/workflows/ci.yml file:

on: [ push, pull_request ]

name: CI
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install Node
        uses: actions/setup-node@v1
        with:
          node-version: '13.x'

      - name: Install Dependencies
        run: npm install

The log itself comes out as a long series of npm WARN tar ENOENT: no such file or directory ala the truncated list below.

2020-04-29T21:15:31.7899082Z npm install
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/acorn-26d8ba97/dist/acorn.js.map'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/coffeescript-acee515b/lib/coffee-script/register.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/coffeescript-acee515b/lib/coffee-script/repl.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/coffeescript-acee515b/lib/coffee-script/rewriter.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/tslint-c216b578/LICENSE'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/eslint-cd3dbe58/LICENSE'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/eslint-cd3dbe58/README.md'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/typescript-b4b55d18/lib/diagnosticMessages.generated.json'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/jquery-1794793b/dist/jquery.min.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-05c1df31/fp/_convertBrowser.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-70e4a396/fp/_convertBrowser.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-79f5ae17/fp/_convertBrowser.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-e49b02f6/fp/_convertBrowser.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-16fa050d/fp/_convertBrowser.js'

The advice I have found online is to rm package-lock.json but that's not an acceptable solution as I need to test our code with the exact versions of our dependencies we have locked.

Further, I don't believe there is anything wrong with our package-lock.json file to begin with because it still npm install 's as expected both locally and on our Drone CI installation.

donatJ
  • 3,105
  • 3
  • 32
  • 51
  • 3
    A long shot, but in my case the issue ended up being that one of the dependencies I referenced in package.json was a private repo. Adding the right SSH keys to GH actions fixed it for me. – Elise May 18 '20 at 13:31
  • @Elise This might be a bigger question than can fit in a comment but how did you end up doing that? – donatJ May 26 '20 at 16:04
  • 5
    I added a step to my workflow that replaces fetching repos via ssh/git with HTTPS and references a private access token for a GH user that has access to the private repo I'm trying to install via npm. The token needs to be added to the "Secrets" list on the repo that is running the workflow. https://gist.github.com/elisehein/5730b5234257403f6b988864f410b2bd – Elise Jun 01 '20 at 10:35

4 Answers4

6

At long wait, I found the solution here:

Install an npm module from a private GitHub repository using GitHub Actions

      - uses: actions/checkout@v2
        with:
          persist-credentials: false
      - uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - run: git config --global url."https://${{ secrets.PAT }}@github.com/".insteadOf ssh://git@github.com/
      - run: npm ci
      ...

I had tried basically all of this on my own but the most important part was missing:

        with:
          persist-credentials: false

actions/checkout@v2 will by default mess with some settings for Git and prevent insteadOf from working properly.

donatJ
  • 3,105
  • 3
  • 32
  • 51
1

This error condition can also happen if you are using a private npm package, and simply forget to add the secret to the repo.

E.g. if you have something like this in your GitHub Actions workflow:

- name: Add token for private package access to .npmrc
  run: echo "//npm.pkg.github.com/:_authToken=$ACME_CORP_TOKEN" > ~/.npmrc
  env:
    ACME_CORP_TOKEN: ${{ secrets.ACME_CORP_TOKEN }}

...an action like the above won't fail if $ACME_CORP_TOKEN doesn't exist (though it would be better to make it do so), so if you've forgotten to actually add the ACME_CORP_TOKEN secret to the repository (in the Secrets tab of the repository settings), then you will get this same problem.

The enormous list of npm WARN tar ENOENT errors for normal-looking dependencies inside of node_modules won't make it obvious that the problem is actually the missing private registry access token.

Mason
  • 5,071
  • 4
  • 25
  • 24
  • I had the same issue with an outdated TOKEN instead of a missing token. No real error messages besides the ENOENT. – meaku Oct 04 '21 at 16:05
0

We had this problem. Buried amongst an unending stream of tar ENOENT errors we spotted this other one (edited for brevity):

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/fivetran/doctrine.git
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! exited with error code: 128

In our case the repository in question is public but for whatever reason npm is nevertheless trying to fetch it by ssh instead of https (unlike all our other dependencies).

We solved the problem simply by adding an extra step to our workflow to configure npm to use https instead:

    steps:
    - uses: actions/checkout@v2
      with:
        persist-credentials: false

    - name: Reconfigure git to use HTTP authentication
      run: >
        git config --global url."https://github.com/".insteadOf
        ssh://git@github.com/

    # etc.
cpcallen
  • 1,834
  • 1
  • 16
  • 27
-1

In my case, one of the files had been renamed from Pascal case to lower case:

Home.vue => home.vue

For unknown reasons, this change had not been replicated to the GitHub repository. (I have seen that happen before on Windows systems but not from my Mac). My solution was to rename the file and appropriate references to it:

home.vue => home-page.vue

SteveC
  • 644
  • 7
  • 12