Fix for GitHub Actions Node.js Build Fails

If your Node.js dependencies fail installing, try this.

The other day all my GitHub actions builds mysteriously stopped working.

The specific error message I received was:

➤ YN0009: unrs-resolver@npm:1.11.1 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-83024323/build.log)

I didn't change anything, so what happened 🤔

Turns out, GitHub had made some changes to their runners. Specifically, they apparently stopped supporting compiling native dependencies as part of Node.js builds on their 'ubuntu-slim' runners.

Good news is that there is an easy fix. Simply switch to the ubuntu-latest runner by changing the runs-on declaration in your workflow files to the following:

  runs-on: ubuntu-latest

Or in the context of a job:

  audit:
    if: ${{ !contains(github.event.head_commit.message, 'skip_ci') }}
    name: '🔒 NPM Audit'
    needs: build
    runs-on: ubuntu-latest
    timeout-minutes: 60
    steps:
      - uses: actions/checkout@v3
      - uses: ./.github/actions/goldstack-setup
      - run: |
          yarn npm audit --all --recursive --severity critical

Bad new is that running your tasks on this runner is significantly more expensive than using the slim runners.

If you are looking for an easy solution to get your Node.js project configured and deployed, please consider checking out my starter project builder: Goldstack. Thank you 😊