aws-amplify / aws-amplify/amplify-hosting
Unclear Build Failure When Deploying New Next JS Typescript Web Application
- 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
d1f07ljk6orudj
### AWS Region
us-east-2
### Amplify Hosting feature
Frontend builds
### Frontend framework
Next.js
### Next.js version
12.0.0
### Next.js router
Pages Router
### Describe the bug
I am trying to deploy my application through AWS Amplify console. It is a Next JS app written in typescript and uses tailwindcss. I have played with the build settings and it now says the build and deployment are succeeding but I still see build failing in logs and unusual warning messages.
Here are my build settings:
version: 1
frontend:
phases:
preBuild:
commands:
- echo "Starting pre-build phase..."
- export NODE_OPTIONS="--max-old-space-size=4096"
- cd soothsayer-marketplace
- echo "Installing NPM packages..."
- npm install -g typescript
- npm install --verbose || echo "NPM install failed."
- echo "Installing eslint-config-next..."
- npm install --save-dev eslint-config-next || echo "eslint-config-next installation failed."
- echo "Checking TypeScript version..."
- npm run type-check || echo "TypeScript version check failed."
build:
commands:
- echo "Starting build phase..."
- echo "Running ESLint..."
- npx eslint . --ext .js,.jsx,.ts,.tsx || echo "ESLint errors."
- echo "Running build command..."
- npm run build --verbose || echo "Build command failed."
artifacts:
baseDirectory: soothsayer-marketplace/.next
files:
- '**/*'
cache:
paths:
- soothsayer-marketplace/node_modules/**/*
I am able to run "npm run build", "npm run dev", "npx eslint . --ext .js,.jsx,.ts,.tsx", and "npx tsc --noEmit" successfully locally but there seem to be issues in the build logs on amplify. There is no good logs that actually show the build failure. The lint and typescript missing warnings are weird because I explciitly install them in the build settings and they are in my package.json. I have attached my tsconfig and package json in this message.
[log (26).txt](https://github.com/aws-amplify/amplify-hosting/files/13401453/log.26.txt)
[package.json](https://github.com/aws-amplify/amplify-hosting/files/13401454/package.json)
[tsconfig.json](https://github.com/aws-amplify/amplify-hosting/files/13401455/tsconfig.json)
### Expected behavior
I am expecting the web app to build successfully and produce the proper build artifacts.
### Reproduction steps
1. Just redeploy the build with the current build settings on the "getReadyProd" branch
### Build Settings
```yaml
version: 1
frontend:
phases:
preBuild:
commands:
- echo "Starting pre-build phase..."
- export NODE_OPTIONS="--max-old-space-size=4096"
- cd soothsayer-marketplace
- echo "Installing NPM packages..."
- npm install -g typescript
- npm install --verbose || echo "NPM install failed."
- echo "Installing eslint-config-next..."
- npm install --save-dev eslint-config-next || echo "eslint-config-next installation failed."
- echo "Checking TypeScript version..."
- npm run type-check || echo "TypeScript version check failed."
build:
commands:
- echo "Starting build phase..."
- echo "Running ESLint..."
- npx eslint . --ext .js,.jsx,.ts,.tsx || echo "ESLint errors."
- echo "Running build command..."
- npm run build --verbose || echo "Build command failed."
artifacts:
baseDirectory: soothsayer-marketplace/.next
files:
- '**/*'
cache:
paths:
- soothsayer-marketplace/node_modules/**/*
```
### Log output
```
# Put your logs below this line
2023-11-18T20:36:21.046Z [INFO]: # Cloning repository: git@github.com:blc16/soothsayer-mvp.git
2023-11-18T20:36:22.026Z [INFO]:
2023-11-18T20:36:22.026Z [INFO]: Cloning into 'soothsayer-mvp'...
2023-11-18T20:36:22.026Z [INFO]: # Switching to commit: 3f07693ed766b78db34c9ae351b1145343f6bbe1
2023-11-18T20:36:22.038Z [INFO]: Note: switching to '3f07693ed766b78db34c9ae351b1145343f6bbe1'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 3f07693 add type checking script
2023-11-18T20:36:22.048Z [INFO]: Successfully cleaned up Git credentials
2023-11-18T20:36:22.049Z [INFO]: # Checking for Git submodules at: /codebuild/output/src842670911/src/soothsayer-mvp/.gitmodules
2023-11-18T20:36:22.053Z [INFO]: # Retrieving environment cache...
2023-11-18T20:36:22.125Z [INFO]: # Retrieved environment cache
2023-11-18T20:36:22.125Z [INFO]: ---- Setting Up SSM Secrets ----
2023-11-18T20:36:22.125Z [INFO]: SSM params {"Path":"/amplify/d1f07ljk6orudj/getReadyProd/","WithDecryption":true}
2023-11-18T20:36:22.158Z [WARNING]: !Failed to set up process.env.secrets
2023-11-18T20:36:22.159Z [INFO]: No live updates for this build run
2023-11-18T20:36:22.162Z [INFO]: # Retrieving cache...
2023-11-18T20:36:26.602Z [INFO]: # Extracting cache...
2023-11-18T20:36:29.794Z [INFO]: # Extraction completed
2023-11-18T20:36:29.944Z [INFO]: # Retrieved cache
2023-11-18T20:36:29.974Z [INFO]: ## Starting Backend Build
## Checking for associated backend environment...
## No backend environment association found, continuing...
## Completed Backend Build
2023-11-18T20:36:29.975Z [INFO]: ## Starting Frontend Build
# Starting phase: preBuild
2023-11-18T20:36:29.976Z [INFO]: # Executing command: echo "Starting pre-build phase..."
Starting pre-build phase...
# Executing command: export NODE_OPTIONS="--max-old-space-size=4096"
# Executing command: cd soothsayer-marketplace
# Executing command: echo "Installing NPM packages..."
Installing NPM packages...
# Executing command: npm install --verbose || echo "NPM install failed."
2023-11-18T20:36:30.175Z [WARNING]: npm
2023-11-18T20:36:30.176Z [WARNING]: verb cli /usr/local/bin/node /usr/local/bin/npm
npm info using npm@9.6.7
npm
2023-11-18T20:36:30.176Z [WARNING]: info using node@v18.17.0
npm verb title npm install
npm verb argv "install" "--loglevel" "verbose"
2023-11-18T20:36:30.176Z [WARNING]: npm
2023-11-18T20:36:30.177Z [WARNING]: verb logfile logs-max:10 dir:/root/.npm/_logs/2023-11-18T20_36_30_160Z-
2023-11-18T20:36:30.183Z [WARNING]: npm verb logfile
2023-11-18T20:36:30.184Z [WARNING]: /root/.npm/_logs/2023-11-18T20_36_30_160Z-debug-0.log
2023-11-18T20:36:30.695Z [WARNING]: npm
2023-11-18T20:36:30.696Z [WARNING]: verb shrinkwrap failed to load node_modules/.package-lock.json out of date, updated: node_modules
2023-11-18T20:36:30.944Z [WARNING]: npm
2023-11-18T20:36:30.945Z [WARNING]: verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-win32-x64-msvc
npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-win32-ia32-msvc
npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-win32-arm64-msvc
npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-linux-arm64-musl
2023-11-18T20:36:30.945Z [WARNING]: npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-linux-arm64-gnu
npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-linux-arm-gnueabihf
npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-freebsd-x64
2023-11-18T20:36:30.945Z [WARNING]: npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-darwin-x64
npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-darwin-arm64
2023-11-18T20:36:30.945Z [WARNING]: npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-android-arm64
2023-11-18T20:36:30.945Z [WARNING]: npm verb reify failed optional dependency /codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/node_modules/@next/swc-android-arm-eabi
2023-11-18T20:36:31.276Z [WARNING]: npm
2023-11-18T20:36:31.277Z [WARNING]: http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 372ms
2023-11-18T20:36:31.375Z [WARNING]: npm http fetch GET 200 https://registry.npmjs.org/postcss 96ms (cache miss)
2023-11-18T20:36:31.477Z [WARNING]: npm http
2023-11-18T20:36:31.478Z [WARNING]: fetch GET 200 https://registry.npmjs.org/next 198ms (cache miss)
2023-11-18T20:36:31.992Z [WARNING]: npm http fetch GET 200 https://registry.npmjs.org/next-auth 260ms (cache miss)
2023-11-18T20:36:32.192Z [INFO]: up to date, audited 461 packages in 2s
2023-11-18T20:36:32.193Z [INFO]: 82 packages are looking for funding
run `npm fund` for details
2023-11-18T20:36:32.212Z [INFO]: 2 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
2023-11-18T20:36:32.212Z [WARNING]: npm
2023-11-18T20:36:32.212Z [WARNING]: verb exit 0
2023-11-18T20:36:32.213Z [WARNING]: npm
2023-11-18T20:36:32.213Z [WARNING]: info ok
2023-11-18T20:36:32.221Z [INFO]: # Executing command: echo "Installing eslint-config-next..."
Installing eslint-config-next...
2023-11-18T20:36:32.221Z [INFO]: # Executing command: npm install --save-dev eslint-config-next || echo "eslint-config-next installation failed."
2023-11-18T20:36:34.084Z [INFO]: up to date, audited 461 packages in 2s
2023-11-18T20:36:34.087Z [INFO]: 82 packages are looking for funding
run `npm fund` for details
2023-11-18T20:36:34.109Z [INFO]: 2 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
2023-11-18T20:36:34.123Z [INFO]: # Executing command: echo "Checking TypeScript version..."
Checking TypeScript version...
2023-11-18T20:36:34.124Z [INFO]: # Executing command: npm run type-check || echo "TypeScript version check failed."
2023-11-18T20:36:34.351Z [INFO]: > soothsayer-marketplace@0.1.0 type-check
> tsc --noEmit
2023-11-18T20:36:34.355Z [WARNING]: sh: 1: tsc: not found
2023-11-18T20:36:34.366Z [INFO]: TypeScript version check failed.
2023-11-18T20:36:34.367Z [INFO]: # Completed phase: preBuild
# Starting phase: build
# Executing command: echo "Starting build phase..."
Starting build phase...
# Executing command: echo "Running ESLint..."
Running ESLint...
# Executing command: npx eslint . --ext .js,.jsx,.ts,.tsx || echo "ESLint errors."
2023-11-18T20:36:35.137Z [WARNING]: npm
2023-11-18T20:36:35.138Z [WARNING]: WARN exec The following package was not found and will be installed: eslint@8.54.0
2023-11-18T20:36:37.305Z [WARNING]: Oops! Something went wrong! :(
ESLint: 8.54.0
ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.
The config "next/core-web-vitals" was referenced from the config file in "/codebuild/output/src842670911/src/soothsayer-mvp/soothsayer-marketplace/.eslintrc.json".
If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
2023-11-18T20:36:37.322Z [INFO]: ESLint errors.
2023-11-18T20:36:37.323Z [INFO]: # Executing command: echo "Running build command..."
Running build command...
# Executing command: npm run build --verbose || echo "Build command failed."
2023-11-18T20:36:37.528Z [WARNING]: npm
2023-11-18T20:36:37.528Z [WARNING]: verb cli /usr/local/bin/node /usr/local/bin/npm
npm info using npm@9.6.7
npm
2023-11-18T20:36:37.528Z [WARNING]: info using node@v18.17.0
npm verb
2023-11-18T20:36:37.528Z [WARNING]: title npm run build
npm verb argv "run" "build" "--loglevel" "verbose"
2023-11-18T20:36:37.528Z [WARNING]: npm verb
2023-11-18T20:36:37.528Z [WARNING]: logfile logs-max:10 dir:/root/.npm/_logs/2023-11-18T20_36_37_507Z-
2023-11-18T20:36:37.535Z [WARNING]: npm verb
2023-11-18T20:36:37.535Z [WARNING]: logfile /root/.npm/_logs/2023-11-18T20_36_37_507Z-debug-0.log
2023-11-18T20:36:37.549Z [INFO]: > soothsayer-marketplace@0.1.0 build
> next build && echo 'Build completed' || (echo 'Build failed with exit code' $? && exit 1)
2023-11-18T20:36:37.921Z [INFO]: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
2023-11-18T20:36:37.937Z [INFO]: Attention: Next.js now collects completely anonymous telemetry regarding usage.
2023-11-18T20:36:37.937Z [INFO]: This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
2023-11-18T20:36:38.048Z [INFO]: info - Linting and checking validity of types...
2023-11-18T20:36:38.182Z [WARNING]: It looks like you're trying to use TypeScript but do not have the required package(s) installed.
Please install typescript by running:
npm install --save-dev typescript
If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).
2023-11-18T20:36:38.211Z [INFO]: Build failed with exit code 1
2023-11-18T20:36:38.213Z [WARNING]: npm
2023-11-18T20:36:38.213Z [WARNING]: verb exit 1
2023-11-18T20:36:38.214Z [WARNING]: npm
2023-11-18T20:36:38.214Z [WARNING]: verb code 1
2023-11-18T20:36:38.220Z [INFO]: Build command failed.
# Completed phase: build
## Completed Frontend Build
2023-11-18T20:36:38.236Z [INFO]: ## Build completed successfully
2023-11-18T20:36:38.238Z [INFO]: # Starting caching...
2023-11-18T20:36:38.250Z [INFO]: # Creating cache artifact...
2023-11-18T20:36:44.957Z [INFO]: # Created cache artifact
2023-11-18T20:36:45.056Z [INFO]: # Uploading cache artifact...
2023-11-18T20:36:47.913Z [INFO]: # Uploaded cache artifact
2023-11-18T20:36:47.914Z [INFO]: # Caching completed
2023-11-18T20:36:47.918Z [INFO]: # No custom headers found.
2023-11-18T20:36:47.945Z [INFO]: # Starting build artifact upload process...
2023-11-18T20:36:47.963Z [INFO]: # Uploading build artifact '__artifacts.zip'...
2023-11-18T20:36:47.965Z [INFO]: # Uploading build artifact '__artifactsHash.zip'...
2023-11-18T20:36:48.060Z [INFO]: # Build artifact upload completed
2023-11-18T20:36:48.160Z [INFO]: # Starting environment caching...
2023-11-18T20:36:48.161Z [INFO]: # Uploading environment cache artifact...
2023-11-18T20:36:48.226Z [INFO]: # Uploaded environment cache artifact
2023-11-18T20:36:48.226Z [INFO]: # Environment caching completed
Terminating logging...
```
### Additional information
_No response_
Contributor guide
Research direction
Start with the attached log (26).txt and compare its frontend build phases with the Build Settings YAML for the getReadyProd branch. Then inspect package.json and tsconfig.json alongside the reported npm, ESLint, and TypeScript warnings; done means the Amplify build completes and produces the expected .next artifacts without the reported failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, next.js, tailwindcss, typescript
- Domain
- ci-cd, cloud, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100