aws-amplify / aws-amplify/amplify-hosting

Turborepo fails when its nested two levels down. CustomerError: The 'node_modules' folder is missing the 'next' dependency.

Open
#4,036 16 comments 4 reactions 0 assignees View on GitHub
bug
Dominant language
Dockerfile
Stars
481
Forks
123
PR merge metrics
No merged PRs in 30d

Description

### Environment information

```plain text
N/A
```

### Describe the bug

A monorepo that has turborepo managing only a subsection of the monorepo fails to deploy NextJS code. If the entire repo is a turborepo then Amplify seems to have no issues with deployment.

Eg: https://github.com/vercel/turborepo/tree/main/examples/basic

The above example deploys without issues.

However when you nest the turborepo under folders like apps/product-frontend like in the example below, it fails to detect the build artifacts as expected

Eg: https://github.com/a3har/turbo-test

It throws the error below.

`
[ERROR]: !!! CustomerError: The 'node_modules' folder is missing the 'next' dependency. This is required at runtime to run your application. If you are using a monorepo framework, you may need to do additionalsetup to ensure the necessary runtime dependencies are included in the build output directory Read more: https://github.com/aws-amplify/amplify-hosting/blob/main/FAQ.md#using-a-monorepo-framework
`

### Reproduction steps

Clone the public repo https://github.com/a3har/turbo-test and use the below build settings to deploy.

Env Variables:
- `AMPLIFY_MONOREPO_APP_ROOT=apps/product-frontend/apps/docs`
- `AMPLIFY_DIFF_DEPLOY=false`

```
version: 1
applications:
- frontend:
buildPath: apps/product-frontend
phases:
preBuild:
commands:
- npm ci --cache .npm --prefer-offline
build:
commands:
- npx turbo build --filter=docs...
artifacts:
baseDirectory: apps/docs/.next
files:
- "**/*"
cache:
paths:
- node_modules/**/*
appRoot: apps/product-frontend/apps/docs
```

Contributor guide

Open the contributing guide

Research direction

Start by cloning the linked turbo-test reproduction and applying the supplied Amplify environment variables and build settings. Compare its nested apps/product-frontend layout with the working turborepo example, then deploy and verify that the Next.js build artifacts are detected without the missing dependency error.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js
Domain
build-system, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.