GitHub Actions - npm run build - debug.log

Hi

I’ve got an Action which builds a React site. Works perfectly locally and similar code works in a different repo but wont build via Actions.

I (think) I’ve narrowed it down to a single file but despite committing single lines at a time and having working elsewhere, I’m getting nowhere

The actions Build and Deploy step log includes:

npm ERR! A complete log of this run can be found in:
npm ERR! /github/home/.npm/_logs/2021-07-04TxxxxxxxxZ-debug.log

How do I access that file?

Ta

Sam

Is the repository public? It could help to see how the project is made and how the workflow is written.

You could try storing the log as an artifact, this would allow you to download a copy of the log.

1 Like

Thanks for responding. The repo isnt public at the moment I’m afraid

Notes:

  • I’m using react
  • I’m deploying to Azure Static Web apps
  • I’ve added the step to output some variables
  • Following your suggestion, I added the step to upload artifacts
  • I’ve added this path and others
    /github/home/.npm/_logs/
    but its responding with
Warning: No files were found with the provided path: 
/home/runner/.npm/_logs/
/github/home/runner/.npm/_logs/
/github/home/.npm/_logs/

Welcome any other suggestions!

YML

on:
  push:
    branches:
      - master
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - master

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: echo-default-env-variables
        run: |
            echo "Home: ${HOME}"
            echo "GITHUB_WORKFLOW: ${GITHUB_WORKFLOW}"
            echo "GITHUB_ACTIONS: ${GITHUB_ACTIONS}"
            echo "GITHUB_ACTOR: ${GITHUB_ACTOR}"
            echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}"
            echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}"
            echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}"
            echo "GITHUB_SHA: ${GITHUB_SHA}"
            echo "GITHUB_REF: ${GITHUB_REF}"
            echo "GITHUB_PATH: ${GITHUB_PATH}"
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "/" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "build" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######
      - name: Archive production logs
        uses: actions/upload-artifact@v2
        if: always()
        with:
          name: logs
          retention-days: 1
          path: |
            /home/runner/.npm/_logs/*
            /github/home/runner/.npm/_logs/*
            /github/home/.npm/_logs/*
            
  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
          action: "close"

Logs

npm ERR! A complete log of this run can be found in:

npm ERR! /github/home/.npm/_logs/2021-07-05T20_48_03_994Z-debug.log

---End of Oryx build logs---
Oryx has failed to build the solution.

I forgot to preface my initial reply with the fact that I am relatively new to GitHub Actions (started playing with it a month ago), I have not tried artifacts yet, and I have never worked with React 🤦.

I am also unfamiliar with Azure and have only a little experience with Docker.

The workflow looks fine to me, I don’t see anything wrong with the configuration. Maybe the artifacts action doesn’t have access to the Docker? I’m unsure how GitHub handles its runnner and Docker actions. Maybe the NPM log is inaccessible from the runner?

Have you checked for any issues on Azure’s static-web-apps?

Thanks :slightly_smiling_face: Largely new to me too!

There is something odd about my code. I can get everything working via Actions with simpler code and its always fine on my desktop

There must be something I’m doing wrong and the logs would be really useful but I cant figure out how to get them! Will keep plodding on or will start again with the code

A little progress

I changed the path for actions/upload-artifact to below. I believe this means upload everything apart from node-modules (which is huge)

  - name: Archive production logs
    uses: actions/upload-artifact@v2
    if: always()
    with:
      retention-days: 1
      path: |
        **
        !/home/runner/work/mysite/mysite/node_modules/**

Unfortunately, it still didn’t include the log files which I assume is because they’re in the Oryx container and I cant access them.

I somehow found this article:
Azure Static Site (Preview) Build And Deploy: ERR! code ELIFECYCLE · Issue #605 · microsoft/Oryx (github.com)
and added this bit

    env:
      CI: false

and everything deploys! I’m not entirely sure where/what these warnings are but that’s for another day