next.js AWS Amplify CustomerError:无法读取package.json中的“下一个”版本

zbdgwd5y  于 2023-05-28  发布在  其他
关注(0)|答案(2)|浏览(175)

我试图部署一个简单的Next.JS应用程序,它只有一个前端,没有后端或数据库连接到AWS Amplify,但我一直在构建时遇到这个错误:

2023-05-20T17:00:51.907Z [INFO]: # Checking for Git submodules at: /codebuild/output/src963349001/src/static/.gitmodules
2023-05-20T17:00:51.911Z [ERROR]: !!! CustomerError: Cannot read 'next' version in package.json.

我不明白为什么它不能读下一个版本。就在包里json:

{
  "name": "one-two-static",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build && next export",
    "start": "next start"
  },
  "dependencies": {
    "@types/node": "20.2.1",
    "@types/react": "18.2.6",
    "@types/react-dom": "18.2.4",
    "autoprefixer": "10.4.14",
    "eslint": "8.41.0",
    "eslint-config-next": "13.4.3",
    "next": "13.4.3",
    "postcss": "8.4.23",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "tailwindcss": "3.3.2",
    "typescript": "5.0.4"
  }
}

下面是我的下一个. config.js:

/** @type {import('next').NextConfig} */
const nextConfig = {
    reactStrictMode: true,
    output: 'standalone',
    experimental: {
      outputStandalone: true,
    }
  }

module.exports = nextConfig
0sgqnhkj

0sgqnhkj1#

我遇到了类似的问题,只需要运行npm install,然后将package.json和package.lock推送到部署为amplify的存储库。
在包构建中包含next export似乎也会导致警告错误,您可以尝试删除它并将其添加到next.config.js

5fjcxozz

5fjcxozz2#

有类似的问题,我通过更改package.json修复了它

"scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },

相关问题