aws-amplify / aws-amplify/amplify-hosting
Hosting Next.js web in Yarn Workspace Monorepo was Failed.
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### App Id
d1c90c3mxyn376
### AWS Region
ap-northeast-2
### Amplify Hosting feature
Monorepo, SSR
### Frontend framework
Next.js
### Next.js version
13
### Next.js router
Pages Router
### Describe the bug
First, My project architecture like below
```
project-root
packages
nextjs-web
.next // build output
...apps
```
I set up deploying next.js web through Amplify but it failed at second step (provisioning > **build**)
### Expected behavior
Build Success
### Reproduction steps

### Build Settings
```yaml
version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn web build # web is alias of nextjs-web package
artifacts:
baseDirectory: packages/nextjs-web/.next
files:
- '**/*'
cache:
paths:
- .yarn/**/*
buildPath: /
appRoot: packages/nextjs-web
customHeaders:
- pattern: /
headers:
- key: Cache-Control
value: s-maxage=10
```
### Log output
```
# Put your logs below this line
2023-11-10T08:05:40.632Z [INFO]: Found customHttp.yml, applying custom headers...
2023-11-10T08:05:40.710Z [ERROR]: !!! CustomerError: Cannot find package: next. Please ensure the dependency is installed correctly
```
### Additional information
I think It looks like it's all over by build. But I don't know what makes it fail after the build.
Contributor guide
Research direction
Start with the provided Amplify build settings and the project-root/packages/nextjs-web layout, focusing on appRoot, buildPath, and the artifact baseDirectory. Review the provisioning build log around “Cannot find package: next” and compare it with the configured yarn install and build commands. Done means the monorepo’s Next.js build completes successfully in Amplify.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, next.js
- Domain
- ci-cd, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100