actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.82k stars 949 forks source link

npm run build in Nextjs application causing an unexpected error which is not occuring on local machine or else #2762

Open rajrupdasofficial opened 1 year ago

rajrupdasofficial commented 1 year ago

Describe the bug A clear and concise description of what the bug is. Next.js build error occurred which is not occurring on gitlab ci pipeline

While developing an application for my client I had used github actions to build and deploy it on AWS beanstalk later

I have developed a minimal static landing page and changed the the favicon.ico as with their requested favicon.ico but noticed it's failing on github actions all of the npm run build command logs has given below

I had ran the command npm run build locally and it ran successfully without any issue my local machine is running on ubuntu latest and on github actions pipeline i am also using ubuntu latest

for clearing my doubt I had spawn up a gitlab ci pipeline on gitlab and ran the same tests with same configurations and it ran successfully

I don't know what is going on with github actions

please check and fix the issue

I can assure you that there is no syntax error in the pipeline where I am trying to run the build configuration

To Reproduce Steps to reproduce the behavior:

  1. install latest nextjs using command npx-create-next-app (press enter) go with all of the prompts
  2. Run : - npm run build after changing the default favicon.ico
  3. See error

Expected behavior A clear and concise description of what you expected to happen. After ran npm run build it should able to run successfully and should able to successfully build and store the build files into artifacts

Runner Version and Platform

Version of your runner? github hosted runner : might be latest

OS of the machine running the runner? OSX/Windows/Linux/... Ubuntu linux latest

What's not working?

Please include error messages and screenshots. Screenshot from 2023-08-13 16-43-15

Job Log Output

If applicable, include the relevant part of the job / step log output here. All sensitive information should already be masked out, but please double-check before pasting here.

Runner and Worker's Diagnostic Logs

If applicable, add relevant diagnostic log information. Logs are located in the runner's _diag folder. The runner logs are prefixed with Runner_ and the worker logs are prefixed with Worker_. Each job run correlates to a worker log. All sensitive information should already be masked out, but please double-check before pasting here.

Next.js Telemetry

Status: Enabled

Next.js telemetry is completely anonymous. Thank you for participating! Learn more: https://nextjs.org/telemetry

Your preference has been saved to /home/runner/work/threads_clone/threads_clone/cache/config.json.

Status: Disabled

You have opted-out of Next.js' anonymous telemetry program. No data will be collected from your machine. Learn more: https://nextjs.org/telemetry

added 413 packages, and audited 414 packages in 10s

111 packages are looking for funding run npm fund for details

found 0 vulnerabilities Next.js Telemetry

Status: Disabled

You have opted-out of Next.js' anonymous telemetry program. No data will be collected from your machine. Learn more: https://nextjs.org/telemetry

Next.js' telemetry collection is already disabled.

Status: Disabled

You have opted-out of Next.js' anonymous telemetry program. No data will be collected from your machine. Learn more: https://nextjs.org/telemetry

threads_clone@0.1.0 build next build

next-app-loader?page=%2F(root)%2Fpage&name=app%2F(root)%2Fpage&pagePath=private-next-app-dir%2F(root)%2Fpage.tsx&appDir=%2Fhome%2Frunner%2Fwork%2Fthreads_clone%2Fthreads_clone%2Fapp&appPaths=%2F(root)%2Fpage&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!:21 Error: Image import "next-metadata-image-loader?type=favicon&segment=&basePath=&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js!/home/runner/work/threads_clone/threads_clone/app/favicon.ico?__next_metadata__" is not a valid image file. The image may be corrupted or an unsupported format.

Build failed because of webpack errors Error: Process completed with exit code 1.

nikola-jokic commented 1 year ago

Hey @RajrupDasid,

Can you please provide an example repro repository or an example workflow file that is causing this issue?

rajrupdasofficial commented 1 year ago

example work flow -> `name: Testing with jest

on: push: branches: [ "main", "hotfix" ] pull_request: branches: [ "main", "hotfix" ]

jobs: build: runs-on: ubuntu-latest

strategy:
  matrix:
    node-version: [18.x]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
  uses: actions/setup-node@v3
  with:
    node-version: ${{ matrix.node-version }}

- name: Build
  run: |
    npx next telemetry status
    npx next telemetry disable
    npm install
    npx next telemetry status
    npx next telemetry disable
    npm run build
    npx next telemetry status
    npx next telemetry disable

- name: Upload Nextjs Build Artifact
  uses: actions/upload-artifact@v3
  with:
    name: build-output
    path: .next
    `

ignore so much npx next telemetery status and disable i was just debugging what happen after a successful build

@nikola-jokic please check and tell me where is the issue I am waiting

NearTox commented 1 month ago

I recently had the same problem, in my case it was that the available memory in my pipeline was insufficient to build my project

rajrupdasofficial commented 1 month ago

I have no idea it solved or not