amplify-hosting
amplify-hosting copied to clipboard
Creating Next.js app from AWS Amplify doesn't detect the framework
Environment information
n/a
Describe the bug
We have a Next.js v15 app deployed to vercel and it works well. Now we want to deploy the exactly same code to AWS Amplify instead. But when we tried to create new app, Amplify cannot detect the correct framework.
Below are screenshots taken while creating the app.
And package.json under packages/ops2-web-app is as below
{
"private": true,
"scripts": {
"build": "next build",
"dev": "next dev --turbo",
"start": "next start"
},
"dependencies": {
"@heroicons/react": "^2.1.4",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.6",
"@tailwindcss/forms": "^0.5.7",
"@vercel/postgres": "^0.8.0",
"apexcharts": "^4.1.0",
"autoprefixer": "10.4.19",
"bcrypt": "^5.1.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
"lucide-react": "^0.460.0",
"next": "^15.0.0",
"next-auth": "5.0.0-beta.19",
"pg": "^8.13.1",
"postcss": "8.4.38",
"react": "^18.3.1",
"react-apexcharts": "^1.6.0",
"react-day-picker": "^8.10.1",
"react-dom": "^18.3.1",
"tailwind-merge": "^2.5.5",
"tailwindcss": "3.4.4",
"typescript": "5.5.2",
"use-debounce": "^10.0.4",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/node": "20.14.8",
"@types/pg": "^8.6.6",
"tailwindcss-animate": "^1.0.7"
}
}
Can anyone shred some light on what could be wrong here?
Thanks!
Reproduction steps
n/a
Hi @cloudhx 👋 , thanks for reaching out to us. Based on the information shared, the baseDirectory within the amplify.yml file is currently set to dist/packages/ops2-web-app/dist. For Next.js applications version 14 and above, the output directory should be configured to .next to support both Static Site Generation (SSG) and Server-Side Rendering (SSR): https://docs.aws.amazon.com/amplify/latest/userguide/deploy-nextjs-app.html#build-setting-detection-ssg-14.
Hi @Jay2113 , thank you for your reply. I made changes following your guide, but it still doesn't seem right, no framework detected. I remembered I tried Amplify a while ago and it should be able to detect Next.js framework automatically. Here are the updated screenshots.
I started the build anyway and it failed with below logs.
2025-01-14T11:13:12.211Z [INFO]: # Cloning repository: [email protected]:xxxxxxx/swm-poc.git
2025-01-14T11:13:13.519Z [INFO]:
2025-01-14T11:13:13.520Z [INFO]: Cloning into 'swm-poc'...
2025-01-14T11:13:13.520Z [INFO]: # Checking for Git submodules at: /codebuild/output/src403436820/src/swm-poc/.gitmodules
2025-01-14T11:13:13.530Z [INFO]: # Retrieving environment cache...
2025-01-14T11:13:13.567Z [WARNING]: ! Unable to write cache: {"code":"ERR_BAD_REQUEST","message":"Request failed with status code 404"})}
2025-01-14T11:13:13.567Z [INFO]: ---- Setting Up SSM Secrets ----
2025-01-14T11:13:13.567Z [INFO]: SSM params {"Path":"/amplify/d5nfvtfn53pka/service-detection/","WithDecryption":true}
2025-01-14T11:13:13.659Z [WARNING]: !Failed to set up process.env.secrets
2025-01-14T11:13:14.277Z [INFO]: # No package override configuration found.
2025-01-14T11:13:14.280Z [INFO]: # Retrieving cache...
2025-01-14T11:13:14.308Z [INFO]: # Retrieved cache
2025-01-14T11:13:16.475Z [INFO]: BackendEnvironment name service-detection for app d5nfvtfn53pka is invalid
2025-01-14T11:13:16.583Z [INFO]: Random environment name mersey generated
2025-01-14T11:13:19.150Z [INFO]: ## Starting Backend Build
## Checking for associated backend environment...
## No backend environment association found, continuing...
2025-01-14T11:13:19.150Z [INFO]: ## Completed Backend Build
2025-01-14T11:13:19.153Z [INFO]: ## Starting Frontend Build
# Starting phase: preBuild
# Executing command: npm install
2025-01-14T11:13:55.156Z [WARNING]: npm WARN deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
2025-01-14T11:13:55.435Z [WARNING]: npm WARN deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
2025-01-14T11:13:55.672Z [WARNING]: npm WARN deprecated
2025-01-14T11:13:55.673Z [WARNING]: [email protected]: Glob versions prior to v9 are no longer supported
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
2025-01-14T11:13:55.673Z [WARNING]: npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
2025-01-14T11:13:55.673Z [WARNING]: npm
2025-01-14T11:13:55.674Z [WARNING]: WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
2025-01-14T11:13:55.677Z [WARNING]: npm WARN
2025-01-14T11:13:55.677Z [WARNING]: deprecated [email protected]: Glob versions prior to v9 are no longer supported
2025-01-14T11:13:55.733Z [WARNING]: npm WARN deprecated [email protected]: This package is no longer supported.
2025-01-14T11:13:55.917Z [WARNING]: npm WARN
2025-01-14T11:13:55.917Z [WARNING]: deprecated [email protected]: This package is no longer supported.
2025-01-14T11:13:56.234Z [WARNING]: npm WARN
2025-01-14T11:13:56.234Z [WARNING]: deprecated [email protected]: This package is no longer supported.
2025-01-14T11:14:17.014Z [INFO]: added 1054 packages, and audited 1071 packages in 46s
2025-01-14T11:14:17.019Z [INFO]: 114 packages are looking for funding
run `npm fund` for details
2025-01-14T11:14:17.071Z [INFO]: 15 vulnerabilities (5 low, 1 moderate, 9 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
2025-01-14T11:14:17.104Z [INFO]: # Completed phase: preBuild
# Starting phase: build
# Executing command: npx nx build ops2-web-app
2025-01-14T11:14:18.229Z [WARNING]: /bin/sh: line 1: hostname: command not found
2025-01-14T11:14:18.395Z [INFO]:
2025-01-14T11:14:18.395Z [INFO]: NX Nx Cloud: Workspace is unable to be authorized. Exiting run.
This workspace is more than three days old and is not connected. Workspaces must be connected within 3 days of creation. Claim your workspace at https://cloud.nx.app.
2025-01-14T11:14:18.410Z [ERROR]: !!! Build failed
2025-01-14T11:14:18.410Z [ERROR]: !!! Error: Command failed with exit code 1
2025-01-14T11:14:18.410Z [INFO]: # Starting environment caching...
2025-01-14T11:14:18.411Z [INFO]: # Environment caching completed