Cannot find module ‘../server/require-hook’ Nextjs Azure Web App deployment via GitHub actions

Trying to deploy this barebones Nextjs app into an Azure Web App (from GitHub Actions) I get the following exception at runtime:

Error: Cannot find module '../server/require-hook'
  Ok
2024-07-13T05:21:05.27594
Require stack:
  Ok
2024-07-13T05:21:05.2759785
- /home/site/wwwroot/node_modules/.bin/next
  Ok
2024-07-13T05:21:05.2759846
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
  Ok
2024-07-13T05:21:05.275989
    at Module._load (node:internal/modules/cjs/loader:986:27)
  Ok
2024-07-13T05:21:05.2759931
    at Module.require (node:internal/modules/cjs/loader:1233:19)
  Ok
2024-07-13T05:21:05.2759972
    at Module.patchedRequire (/agents/nodejs/node_modules/diagnostic-channel/dist/src/patchRequire.js:16:46)
  Ok
2024-07-13T05:21:05.2760016
    at Hook._require.Module.require (/agents/nodejs/node_modules/require-in-the-middle/index.js:167:34)
  Ok
2024-07-13T05:21:05.276006
    at require (node:internal/modules/helpers:179:18)
  Ok
2024-07-13T05:21:05.27601
    at Object.<anonymous> (/home/site/wwwroot/node_modules/.bin/next:6:1)
  Ok
2024-07-13T05:21:05.2760147
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
  Ok
2024-07-13T05:21:05.2760187
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
  Ok
2024-07-13T05:21:05.2760226
    at Module.load (node:internal/modules/cjs/loader:1208:32) {
  Ok
2024-07-13T05:21:05.2760349
  code: 'MODULE_NOT_FOUND',
  Ok
2024-07-13T05:21:05.2760387
  requireStack: [ '/home/site/wwwroot/node_modules/.bin/next' ]
  Ok
2024-07-13T05:21:05.2760428
}

The deployment works if done via VSCode with the Azure Extensions but I need it to be automated via GitHub Actions.

The deployment file is the default one Azure provides when setting up the continuous integration. Any ideas how to fix it?

My yml in case you don’t want to open the link:

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js app to Azure Web App - nextjs-az-template

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set up Node.js version
        uses: actions/setup-node@v3
        with:
          node-version: '20.x'

      - name: npm install, build, and test
        run: |
          npm install
          npm run build --if-present
          npm run test --if-present

      - name: Zip artifact for deployment
        run: zip release.zip ./* -r

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: node-app
          path: release.zip

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
    
    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: node-app

      - name: Unzip artifact for deployment
        run: unzip release.zip
      
      - name: 'Deploy to Azure Web App'
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v3
        with:
          app-name: 'nextjs-az-template'
          slot-name: 'Production'
          package: .
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_FB5C5356BD1A48A79DF07D1243712E42 }}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật