在AWS Amplify上部署nextjs应用程序时遇到问题

qgzx9mmu  于 2023-11-18  发布在  其他
关注(0)|答案(1)|浏览(111)

因此,我一直在尝试将我的应用程序部署在AWS Amplify上。
它目前在构建过程的前端部分失败。
一些信息:

**next.config.js**
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
}

module.exports = nextConfig
.eslintrc.json

{
  "extends": ["next/babel","next/core-web-vitals"]
}
package.json
{
  "name": "kruegerandco",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@radix-ui/react-dropdown-menu": "^2.0.5",
    "@types/node": "20.4.1",
    "@types/react": "18.2.14",
    "@types/react-dom": "18.2.6",
    "autoprefixer": "10.4.14",
    "class-variance-authority": "^0.6.1",
    "clsx": "^1.2.1",
    "eslint": "8.44.0",
    "eslint-config-next": "13.4.9",
    "hamburger-react": "^2.5.0",
    "lucide-react": "^0.259.0",
    "next": "13.4.9",
    "postcss": "8.4.25",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-icons": "^4.10.1",
    "tailwind-merge": "^1.13.2",
    "tailwindcss": "3.3.2",
    "tailwindcss-animate": "^1.0.6",
    "typescript": "5.1.6"
  }
}

以下是Amplify中部署日志的错误:

2023-07-10T11:45:25.246Z [WARNING]: 
2023-07-10T11:45:25.247Z [WARNING]: > Build error occurred
2023-07-10T11:45:25.249Z [WARNING]: [Error: ENOENT: no such file or directory, lstat '/codebuild/output/src923177214/src/kruegerandco/.next/server/app'] {
                                    errno: -2,
                                    code: 'ENOENT',
                                    syscall: 'lstat',
                                    path: '/codebuild/output/src923177214/src/kruegerandco/.next/server/app'
                                    }
2023-07-10T11:45:25.282Z [ERROR]: !!! Build failed
2023-07-10T11:45:25.282Z [INFO]: Please check the supported SSR features to find if your build failure is related to an unsupported feature: https://docs.aws.amazon.com/amplify/latest/userguide/ssr-Amplify-support.html#supported-unsupported-features. You may also find this troubleshooting guide useful: https://docs.aws.amazon.com/amplify/latest/userguide/troubleshooting-ssr-deployment.html
2023-07-10T11:45:25.283Z [ERROR]: !!! Non-Zero Exit Code detected
2023-07-10T11:45:25.283Z [INFO]: # Starting environment caching...
2023-07-10T11:45:25.283Z [INFO]: # Environment caching completed


它显示它正在寻找一个.next/server/app,但我有一个pages文件夹。
x1c 0d1x的数据
如果我的amplify.yml:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*


请帮助我解决这个令人沮丧的问题!谢谢!

deikduxw

deikduxw1#

我通过在amplify中添加构建应用程序来解决这个错误,以使用next的最新版本和node js docker image version 18作为最低版本。我在amplify中遇到了很多问题,我仍然在努力解决它。默认情况下,Amplify使用node 16,这使得最新版本的next Js出现了一些问题。

相关问题