aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
461 stars 116 forks source link

Error: Cannot find module 'next/dist/server/lib/start-server.js' #3882

Closed MasatoraAtarashi closed 4 months ago

MasatoraAtarashi commented 11 months ago

Before opening, please confirm:

App Id

d1n935d7e6mk91

AWS Region

ap-southeast-1

Amplify Hosting feature

Monorepo

Frontend framework

Next.js

Next.js version

13.5.6

Next.js router

Pages Router

Describe the bug

Expected behavior

Website is accessible after build.

Reproduction steps

I have prepared a repository here to reproduce the issue: https://github.com/MasatoraAtarashi/amplify-monorepo-experiment2

  1. Deploy the above repository with Amplify.
  2. Access the website via custom domain or amplifyapp domain.

Build Settings

version: 1
applications:
  - appRoot: front/apps/app1
    frontend:
      buildPath: /front
      phases:
        preBuild:
          commands:
            - npm install
        build:
          commands:
            - npm run build --workspace=app1
      artifacts:
        baseDirectory: apps/app1/.next
        files:
          - '**/*'
      cache:
        paths:
          - node_modules/**/*

Log output

``` 2023-12-26T22:07:18.192+09:00 | LOGS Name: bootstrap State: Subscribed Types: [Platform, Function] -- | --   | 2023-12-26T22:07:18.340+09:00 | node:internal/modules/cjs/loader:1031   | 2023-12-26T22:07:18.340+09:00 | throw err;   | 2023-12-26T22:07:18.340+09:00 | ^   | 2023-12-26T22:07:18.340+09:00 | Error: Cannot find module 'next/dist/server/lib/start-server.js'   | 2023-12-26T22:07:18.340+09:00 | Require stack:   | 2023-12-26T22:07:18.340+09:00 | - /tmp/app/server.js   | 2023-12-26T22:07:18.340+09:00 | at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1028:15)   | 2023-12-26T22:07:18.340+09:00 | at Function.Module._load (node:internal/modules/cjs/loader:873:27)   | 2023-12-26T22:07:18.340+09:00 | at Module.require (node:internal/modules/cjs/loader:1100:19)   | 2023-12-26T22:07:18.340+09:00 | at require (node:internal/modules/cjs/helpers:119:18)   | 2023-12-26T22:07:18.340+09:00 | at Object. (/tmp/app/server.js:1:517)   | 2023-12-26T22:07:18.340+09:00 | at Module._compile (node:internal/modules/cjs/loader:1198:14)   | 2023-12-26T22:07:18.340+09:00 | at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)   | 2023-12-26T22:07:18.340+09:00 | at Module.load (node:internal/modules/cjs/loader:1076:32)   | 2023-12-26T22:07:18.340+09:00 | at Function.Module._load (node:internal/modules/cjs/loader:911:12)   | 2023-12-26T22:07:18.340+09:00 | at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {   | 2023-12-26T22:07:18.340+09:00コピーcode: 'MODULE_NOT_FOUND', | code: 'MODULE_NOT_FOUND',   | 2023-12-26T22:07:18.340+09:00 | requireStack: [ '/tmp/app/server.js' ]   | 2023-12-26T22:07:18.340+09:00 | } ```

Additional information

No response

github-actions[bot] commented 4 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

github-actions[bot] commented 4 months ago

This issue has been automatically locked.