Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks done
MasatoraAtarashi opened this issue Dec 26, 2023 · 0 comments
Open
5 tasks done

Comments

@MasatoraAtarashi
Copy link

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

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

  • I am trying to host a monorepo using npm workspace.
  • When deploying a repository where the repository root and monorepo root are different, the deployment succeeds, but the application returns a 500 error.
  • When experimenting with a repository where the repository root and monorepo root are the same (https://github.com/MasatoraAtarashi/amplify-monorepo-npm-workspace), it worked successfully.

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.<anonymous> (/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant