AWS Amplify 客户端错误:无法读取 package.json 中的 ‘next’ 版本。

huangapple go评论64阅读模式
英文:

AWS Amplify CustomerError: Cannot read 'next' version in package.json

问题

I'm trying to deploy a simple Next.JS app that has just a front-end with no back-end or database connections to AWS Amplify but I keep getting this error on the build:

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.

I don't understand why it can't read the next version. It's right here in the package.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"
  }
}

Here is my next.config.js:

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

module.exports = nextConfig
英文:

I'm trying to deploy a simple Next.JS app that has just a front-end with no back-end or database connections to AWS Amplify but I keep getting this error on the build:

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.

I don't understand why it can't read the next version. It's right here in the package.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"
  }
}

Here is my next.config.js:

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

module.exports = nextConfig

答案1

得分: 2

我遇到了类似的问题,只需运行 npm install,然后将 package.json 和 package.lock 推送到部署到 Amplify 的存储库即可。

另外,似乎在包构建中使用 next export 可能会导致警告错误,您可以尝试将其移除,并将其添加到 next.config.js 中。

英文:

I had a similiar issue and just needed to run npm install and then push package.json and package.lock to the repository that deployed to amplify.

It also seems like having next export in the package build can cause warning errors, you can try removing this and adding it into the next.config.js

答案2

得分: 0

我通过更改 package.json 文件来解决了类似的问题。

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

Had similar issue and I fixed it by changing package.json

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

huangapple
  • 本文由 发表于 2023年5月21日 01:48:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76296605.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定