Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github action for `yarn build` fails with missing React component

I have a React app that builds correctly locally with yarn build. I have the following job in my config for Github Actions to deploy the app to S3:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v1

    - name: Configure AWS Credentials
      uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: us-east-2

    - name: Install dependencies
      run: yarn install

    - name: Build
      run: yarn build

    - name: Deploy static site to S3 bucket
      run: aws s3 sync build/ s3://my-s3-bucket --delete

The Build phase is failing with this error:

Module not found: Error: Can't resolve './components/Layout' in '/home/runner/work/storefront-app/storefront-app/src'

This module does exist under the src/components/ directory, so I'm not sure why it can't be found. I'm exporting it with export default Layout;

like image 236
KJ0797 Avatar asked Oct 19 '25 05:10

KJ0797


1 Answers

So I found that the issue was with filenames and Git.

Locally, all my files were named correctly: Nav.js, Layout.js, etc. On Github, they were downcased: layout.js. Git never picked up the change to the filename, and so the build on GH could not find ./components/Layout. Deleting the files and re-committing them solved the problem.

like image 73
KJ0797 Avatar answered Oct 21 '25 23:10

KJ0797