next.jsaws-amplify

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

Solution

  • 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