aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
459 stars 116 forks source link

Next JS - Build Error with hybrid SSR / SSG Deployment #2884

Open NilsJacobsen opened 2 years ago

NilsJacobsen commented 2 years ago

Before opening, please confirm:

App Id

964326755670

Region

eu-central-1

Amplify Hosting feature

Build settings

Describe the bug

I tried to host my Next.js App with SSR, SSG, ISR. But I got the following error in the frontend step. A deployment with only SSR on Amplify worked perfectly. Beyond that my SSR, SSG, ISR setup worked fine locally.

2022-07-24T16:19:12.668Z [INFO]: # Cloning repository: git@gitlab.com:***/***.git
2022-07-24T16:19:16.664Z [INFO]: Agent pid 141
2022-07-24T16:19:16.737Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
                                 Cloning into '***'...
                                 Warning: Permanently added the ECDSA host key for IP address '172.65.251.78' to the list of known hosts.
2022-07-24T16:19:16.737Z [INFO]: # Switching to commit: 5752f15d115c463af22fa5b120d53001754ae361
2022-07-24T16:19:16.784Z [INFO]: Agent pid 154
2022-07-24T16:19:16.784Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
                                 Note: switching to '5752f15d115c463af22fa5b120d53001754ae361'.
                                 You are in 'detached HEAD' state. You can look around, make experimental
                                 changes and commit them, and you can discard any commits you make in this
                                 state without impacting any branches by switching back to a branch.
                                 If you want to create a new branch to retain commits you create, you may
                                 do so (now or later) by using -c with the switch command. Example:
                                 git switch -c <new-branch-name>
                                 Or undo this operation with:
                                 git switch -
                                 Turn off this advice by setting config variable advice.detachedHead to false
                                 HEAD is now at 5752f15 enabled ssr in ampliofy
2022-07-24T16:19:16.872Z [INFO]: Successfully cleaned up Git credentials
2022-07-24T16:19:16.872Z [INFO]: # Checking for Git submodules at: /codebuild/output/src175539022/src/homeofopensource/.gitmodules
2022-07-24T16:19:16.898Z [INFO]: # Retrieving environment cache...
2022-07-24T16:19:16.952Z [INFO]: # Retrieved environment cache
2022-07-24T16:19:16.953Z [INFO]: ---- Setting Up SSM Secrets ----
2022-07-24T16:19:16.953Z [INFO]: SSM params {"Path":"/amplify/dqjh6lcvjv24j/dev/","WithDecryption":true}
2022-07-24T16:19:26.001Z [INFO]: # Node version 14.17.0 is available for installation
2022-07-24T16:19:26.077Z [INFO]: # Installing Node version 14.17.0
2022-07-24T16:19:32.991Z [INFO]: # Now using Node version 14.17.0
2022-07-24T16:19:34.906Z [WARNING]: Cannot find module '/root/.nvm/versions/node/v14.17.0/lib/node_modules/@aws-amplify/cli/package.json'
                                    Require stack:
                                    - /snapshot/AWSMobilePioneerExecute/src/plugins/patch/npm.js
                                    - /snapshot/AWSMobilePioneerExecute/src/plugins/patch/patch.js
                                    - /snapshot/AWSMobilePioneerExecute/pioneer.js
2022-07-24T16:19:34.907Z [INFO]: # Patching NPM package '@aws-amplify/cli' to 9.1.0...
2022-07-24T16:19:54.973Z [INFO]: # Done patching NPM package '@aws-amplify/cli' to version 9.1.0
2022-07-24T16:19:55.231Z [INFO]: # Last deployed commit: 5e4c69fe136d4877b417ff7c9651ef24be0c417f
2022-07-24T16:19:55.983Z [INFO]: # Retrieving cache...
2022-07-24T16:20:06.358Z [INFO]: # Extracting cache...
2022-07-24T16:20:13.416Z [INFO]: # Extraction completed
2022-07-24T16:20:17.695Z [INFO]: ## Starting Backend Build
                                 # Starting phase: build
2022-07-24T16:20:19.685Z [INFO]: Amplify AppID found: dqjh6lcvjv24j. Amplify App name is: homeofos
2022-07-24T16:20:19.736Z [INFO]: Backend environment dev found in Amplify Console app: homeofos
2022-07-24T16:20:20.371Z [WARNING]: - Fetching updates to backend environment: dev from the cloud.
2022-07-24T16:20:20.958Z [WARNING]: ✔ Successfully pulled backend environment dev from the cloud.
2022-07-24T16:20:20.963Z [INFO]: ✅
2022-07-24T16:20:22.522Z [INFO]: Note: It is recommended to run this command from the root of your app directory
2022-07-24T16:20:23.356Z [WARNING]: - Initializing your environment: dev
2022-07-24T16:20:23.854Z [WARNING]: ✔ Initialized provider successfully.
2022-07-24T16:20:23.900Z [WARNING]: - Updating resources in the cloud. This may take a few minutes...
2022-07-24T16:20:24.473Z [INFO]: ✅ Initialized your environment successfully.
2022-07-24T16:20:24.475Z [INFO]: Your project has been successfully initialized and connected to the cloud!
                                 Some next steps:
                                 "amplify status" will show you what you've added already and if it's locally configured or deployed
                                 "amplify add <category>" will allow you to add features like user login or a backend API
                                 "amplify push" will build all your local backend resources and provision it in the cloud
                                 "amplify console" to open the Amplify Console and view your project status
                                 "amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud
                                 Pro tip:
                                 Try "amplify add api" to create a backend API and then "amplify push" to deploy everything
                                 ⚠️ The maximum number of apps that you can create with Amplify in this region has likely been reached:
                                 For more information on Amplify Service Quotas, see:
                                 https://docs.aws.amazon.com/general/latest/gr/amplify.html#service-quotas-amplify
2022-07-24T16:20:26.353Z [INFO]: # Completed phase: build
                                 ## Completed Backend Build
2022-07-24T16:20:26.356Z [INFO]: ## Starting Frontend Build
                                 # Starting phase: preBuild
2022-07-24T16:20:26.357Z [INFO]: # Executing command: yarn install
2022-07-24T16:20:26.612Z [INFO]: yarn install v1.22.0
2022-07-24T16:20:26.724Z [INFO]: [1/4] Resolving packages...
2022-07-24T16:20:27.265Z [INFO]: [2/4] Fetching packages...
2022-07-24T16:21:10.786Z [INFO]: info @next/swc-darwin-arm64@11.1.4: The platform "linux" is incompatible with this module.
2022-07-24T16:21:10.793Z [INFO]: info "@next/swc-darwin-arm64@11.1.4" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/swc-darwin-arm64@11.1.4: The CPU architecture "x64" is incompatible with this module.
                                 info @next/swc-darwin-x64@11.1.4: The platform "linux" is incompatible with this module.
                                 info "@next/swc-darwin-x64@11.1.4" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info @next/swc-win32-x64-msvc@11.1.4: The platform "linux" is incompatible with this module.
                                 info "@next/swc-win32-x64-msvc@11.1.4" is an optional dependency and failed compatibility check. Excluding it from installation.
                                 info fsevents@2.3.2: The platform "linux" is incompatible with this module.
                                 info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
2022-07-24T16:21:10.824Z [INFO]: [3/4] Linking dependencies...
2022-07-24T16:21:10.827Z [WARNING]: warning " > @urql/devtools@2.0.3" has unmet peer dependency "@urql/core@>= 1.14.0".
2022-07-24T16:21:10.829Z [WARNING]: warning " > autoprefixer@10.4.7" has unmet peer dependency "postcss@^8.1.0".
2022-07-24T16:21:10.830Z [WARNING]: warning "aws-amplify > @aws-amplify/analytics > @aws-sdk/client-firehose > @aws-sdk/middleware-retry > react-native-get-random-values@1.8.0" has unmet peer dependency "react-native@>=0.56".
2022-07-24T16:21:10.832Z [WARNING]: warning "react-hot-toast > goober@2.1.9" has unmet peer dependency "csstype@^3.0.10".
2022-07-24T16:21:10.833Z [WARNING]: warning "react-notion-x > react-image@4.0.3" has unmet peer dependency "@babel/runtime@>=7".
2022-07-24T16:21:10.833Z [WARNING]: warning "react-notion-x > react-lazy-images@1.1.0" has incorrect peer dependency "react@^15 || ^16".
                                    warning "react-notion-x > react-lazy-images@1.1.0" has incorrect peer dependency "react-dom@^15 || ^16".
2022-07-24T16:21:10.835Z [WARNING]: warning "react-notion-x > react-pdf > file-loader@6.2.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
2022-07-24T16:21:10.839Z [WARNING]: warning " > tailwindcss@3.0.24" has unmet peer dependency "postcss@^8.0.9".
2022-07-24T16:21:11.004Z [WARNING]: warning Workspaces can only be enabled in private projects.
2022-07-24T16:21:28.234Z [INFO]: [4/4] Building fresh packages...
2022-07-24T16:21:45.521Z [INFO]: $ husky install
2022-07-24T16:21:45.582Z [INFO]: husky - Git hooks installed
2022-07-24T16:21:45.585Z [INFO]: Done in 78.98s.
2022-07-24T16:21:45.617Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
                                 # Executing command: yarn run build
2022-07-24T16:21:45.751Z [INFO]: yarn run v1.22.0
2022-07-24T16:21:45.785Z [INFO]: $ yarn run generate
2022-07-24T16:21:45.962Z [INFO]: $ yarn run generate:prisma && yarn run generate:graphql-codegen
2022-07-24T16:21:46.137Z [INFO]: $ prisma generate
2022-07-24T16:21:47.303Z [INFO]: Prisma schema loaded from src/server/db/schema.prisma
2022-07-24T16:21:48.783Z [INFO]: ✔ Generated Prisma Client (3.14.0 | library) to ./node_modules/@prisma/client in 244ms
                                 ✔ Generated Pothos integration to ./src/server/graphql/pothos-types.generated.ts in 47ms
                                 You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
                             import { PrismaClient } from '@prisma/client'
                             const prisma = new PrismaClient()
                             ```

2022-07-24T16:21:49.017Z [INFO]: $ graphql-codegen 2022-07-24T16:21:49.707Z [INFO]: [16:21:49] Parse configuration [started] 2022-07-24T16:21:49.709Z [INFO]: [16:21:49] Parse configuration [completed] 2022-07-24T16:21:49.710Z [INFO]: [16:21:49] Generate outputs [started] 2022-07-24T16:21:49.711Z [INFO]: [16:21:49] Generate src/client/graphql/types.generated.ts [started] 2022-07-24T16:21:49.711Z [INFO]: [16:21:49] Generate to ./ (using EXPERIMENTAL preset "near-operation-file") [started] 2022-07-24T16:21:49.711Z [INFO]: [16:21:49] Load GraphQL schemas [started] 2022-07-24T16:21:49.711Z [INFO]: [16:21:49] Load GraphQL schemas [started] 2022-07-24T16:21:49.750Z [INFO]: [16:21:49] Load GraphQL schemas [completed] 2022-07-24T16:21:49.751Z [INFO]: [16:21:49] Load GraphQL schemas [completed] [16:21:49] Load GraphQL documents [started] [16:21:49] Load GraphQL documents [started] 2022-07-24T16:21:50.690Z [INFO]: [16:21:50] Load GraphQL documents [completed] 2022-07-24T16:21:50.690Z [INFO]: [16:21:50] Load GraphQL documents [completed] [16:21:50] Generate [started] [16:21:50] Generate [started] 2022-07-24T16:21:50.811Z [INFO]: [16:21:50] Generate [completed] 2022-07-24T16:21:50.812Z [INFO]: [16:21:50] Generate [completed] [16:21:50] Generate src/client/graphql/types.generated.ts [completed] [16:21:50] Generate to ./ (using EXPERIMENTAL preset "near-operation-file") [completed] [16:21:50] Generate outputs [completed] 2022-07-24T16:21:51.976Z [INFO]: $ next build 2022-07-24T16:21:52.699Z [INFO]: info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5 2022-07-24T16:21:52.817Z [INFO]: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache 2022-07-24T16:21:52.829Z [INFO]: Attention: Next.js now collects completely anonymous telemetry regarding usage. 2022-07-24T16:21:52.829Z [INFO]: This information is used to shape Next.js' roadmap and prioritize features. You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL: https://nextjs.org/telemetry 2022-07-24T16:21:52.862Z [INFO]: info - Checking validity of types... 2022-07-24T16:22:10.305Z [WARNING]: error - ESLint must be installed in order to run during builds: yarn add --dev eslint 2022-07-24T16:22:10.307Z [INFO]: info - Creating an optimized production build... 2022-07-24T16:22:46.523Z [INFO]: info - Compiled successfully info - Collecting page data... 2022-07-24T16:22:49.643Z [INFO]: info - Generating static pages (0/17) 2022-07-24T16:22:51.264Z [INFO]: info - Generating static pages (4/17) 2022-07-24T16:22:52.217Z [INFO]: info - Generating static pages (8/17) 2022-07-24T16:22:52.897Z [INFO]: info - Generating static pages (12/17) 2022-07-24T16:22:53.270Z [INFO]: info - Generating static pages (17/17) 2022-07-24T16:22:53.289Z [INFO]: info - Finalizing page optimization... 2022-07-24T16:22:53.295Z [INFO]: 2022-07-24T16:22:53.312Z [INFO]: Page Size First Load JS ┌ ○ / (936 ms) 19.5 kB 1.04 MB ├ ○ /workspace 841 B 137 kB ├ ○ /workspace/[slug] 7.35 kB 1.02 MB ├ └ css/17d35c37ffa88498e134.css 931 B ├ ○ /workspace/[slug]/ideas/[id] (1141 ms) 3.06 kB 1.01 MB ├ ○ /workspace/[slug]/settings (1171 ms) 828 B 1.02 MB ├ /_app 0 B 132 kB ├ ○ /404 194 B 132 kB ├ λ /api 0 B 132 kB ├ λ /api/auth/[...nextauth] 0 B 132 kB ├ λ /api/aws 0 B 132 kB ├ λ /api/aws/upload-url 0 B 132 kB ├ λ /api/invitations/accept 0 B 132 kB ├ λ /api/mailchimp/subscribe 0 B 132 kB ├ λ /api/stripe/webhooks 0 B 132 kB ├ ○ /auth/error 1.1 kB 133 kB ├ λ /auth/login 6.25 kB 138 kB ├ ○ /auth/verify-request (1383 ms) 4.32 kB 136 kB ├ ● /blog (ISR: 10 Seconds) (836 ms) 602 B 167 kB ├ ● /blog/[pageId] 607 B 167 kB ├ ○ /check-mailbox (1145 ms) 485 B 133 kB ├ ○ /get-started (1209 ms) 695 B 133 kB ├ ● /legal (ISR: 10 Seconds) (335 ms) 7.25 kB 174 kB ├ ● /manifesto (ISR: 10 Seconds) 7.25 kB 174 kB ├ ● /privacy (ISR: 10 Seconds) (410 ms) 8.18 kB 140 kB └ ○ /signup 3.08 kB 135 kB

My Nextjs App structure:

--pages --->_app(recoil, react router, SSR) --->api(ISR) --->blog(ISR) ------>pageId --->legal(ISR) --->privacy(ISR) --->manifesto(ISR)

The reported pages that seam to lead to this error are the ISR pages. They are using getStaticProps of Nextjs to load data from a Notion CMS. The files look all similar like that one:


import { ExtendedRecordMap } from "notion-types";

import NotionPage from "../../client/components/00_Marketing/NotionPage";
import { legalPageId } from "../../client/notion/config";
import notion from "../../client/notion/notion";

export const getStaticProps = async () => {
  const pageId = legalPageId;
  const recordMap = await notion.getPage(pageId);

  return {
    props: {
      recordMap,
    },
    revalidate: 10,
  };
};

export default function LegalPage({
  recordMap,
}: {
  recordMap: ExtendedRecordMap;
}) {
  return (
    <>
      <Layout>
        <NotionPage recordMap={recordMap} rootPageId={legalPageId} />
      </Layout>
    </>
  );
}

Expected behavior

I expected the deployment to just work with the package.json.

Reproduction steps

I followed the instructions on that website: https://docs.amplify.aws/guides/hosting/nextjs/q/platform/js/#getting-started-1

I added the environmental variable AMPLIFY_NEXTJS_EXPERIMENTAL_TRACE = true

image

Build Settings

`version: 1
backend:
  phases:
    # IMPORTANT - Please verify your build commands
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - yarn install

    build:
      commands: 
        - yarn run build
  artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
`

Additional information

No response

ghost commented 2 years ago

Hi @NilsJacobsen 👋🏽 can you also provide your next.config.js file as well?

NilsJacobsen commented 2 years ago

Hi @hloriana :)

const withPrismaPlugin = require("next-prisma-plugin-webpack5");

module.exports = withPrismaPlugin({
  webpackDevMiddleware: (config) => {
    if (process.env.IS_DOCKER) {
      config.watchOptions = {
        ...config.watchOptions,
        poll: 500,
      };
    }
    return config;
  },
});

// eslint-disable-next-line @typescript-eslint/no-var-requires
const withBundleAnalyzer = require("@next/bundle-analyzer")({
  enabled: process.env.ANALYZE === "true",
});

module.exports = withBundleAnalyzer({
  staticPageGenerationTimeout: 300,
  images: {
    domains: [
      "www.notion.so",
      "notion.so",
      "images.unsplash.com",
      "pbs.twimg.com",
    ],
    formats: ["image/avif", "image/webp"],
  },
});

module.exports = {
  async rewrites() {
    return [
      {
        source: "/app/:any*",
        destination: "/",
      },
    ];
  },
};
ghost commented 2 years ago

@NilsJacobsen It looks like the AMPLIFY_NEXTJS_EXPERIMENTAL_TRACE variable is not being detected as set to true. Can you add this to your next.config.js as well and redeploy:

module.exports = {
  target: "experimental-serverless-trace"
};
NilsJacobsen commented 2 years ago

Again a build error. But this time I also get 'Non-Zero Exit Code detected'.

2022-07-25T19:16:10.170Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
2022-07-25T19:16:10.170Z [INFO]: # Executing command: yarn run build
2022-07-25T19:16:10.293Z [INFO]: yarn run v1.22.0
2022-07-25T19:16:10.325Z [INFO]: $ yarn run generate
2022-07-25T19:16:10.501Z [INFO]: $ yarn run generate:prisma && yarn run generate:graphql-codegen
2022-07-25T19:16:10.678Z [INFO]: $ prisma generate
2022-07-25T19:16:11.808Z [INFO]: Prisma schema loaded from src/server/db/schema.prisma
2022-07-25T19:16:13.259Z [INFO]: ✔ Generated Prisma Client (3.14.0 | library) to ./node_modules/@prisma/client in 249ms
                                 ✔ Generated Pothos integration to ./src/server/graphql/pothos-types.generated.ts in 46ms
                                 You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
                             import { PrismaClient } from '@prisma/client'
                             const prisma = new PrismaClient()
                             ```

2022-07-25T19:16:13.498Z [INFO]: $ graphql-codegen 2022-07-25T19:16:14.186Z [INFO]: [19:16:14] Parse configuration [started] 2022-07-25T19:16:14.188Z [INFO]: [19:16:14] Parse configuration [completed] 2022-07-25T19:16:14.188Z [INFO]: [19:16:14] Generate outputs [started] 2022-07-25T19:16:14.189Z [INFO]: [19:16:14] Generate src/client/graphql/types.generated.ts [started] 2022-07-25T19:16:14.189Z [INFO]: [19:16:14] Generate to ./ (using EXPERIMENTAL preset "near-operation-file") [started] 2022-07-25T19:16:14.189Z [INFO]: [19:16:14] Load GraphQL schemas [started] 2022-07-25T19:16:14.189Z [INFO]: [19:16:14] Load GraphQL schemas [started] 2022-07-25T19:16:14.228Z [INFO]: [19:16:14] Load GraphQL schemas [completed] 2022-07-25T19:16:14.229Z [INFO]: [19:16:14] Load GraphQL schemas [completed] [19:16:14] Load GraphQL documents [started] [19:16:14] Load GraphQL documents [started] 2022-07-25T19:16:15.175Z [INFO]: [19:16:15] Load GraphQL documents [completed] 2022-07-25T19:16:15.175Z [INFO]: [19:16:15] Load GraphQL documents [completed] [19:16:15] Generate [started] [19:16:15] Generate [started] 2022-07-25T19:16:15.300Z [INFO]: [19:16:15] Generate [completed] 2022-07-25T19:16:15.301Z [INFO]: [19:16:15] Generate [completed] [19:16:15] Generate src/client/graphql/types.generated.ts [completed] [19:16:15] Generate to ./ (using EXPERIMENTAL preset "near-operation-file") [completed] [19:16:15] Generate outputs [completed] 2022-07-25T19:16:16.445Z [INFO]: $ next build 2022-07-25T19:16:17.141Z [INFO]: info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5 2022-07-25T19:16:17.259Z [INFO]: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache 2022-07-25T19:16:17.272Z [INFO]: Attention: Next.js now collects completely anonymous telemetry regarding usage. 2022-07-25T19:16:17.272Z [INFO]: This information is used to shape Next.js' roadmap and prioritize features. You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL: https://nextjs.org/telemetry 2022-07-25T19:16:17.305Z [INFO]: info - Checking validity of types... 2022-07-25T19:16:34.592Z [WARNING]: error - ESLint must be installed in order to run during builds: yarn add --dev eslint 2022-07-25T19:16:34.594Z [INFO]: info - Creating an optimized production build... 2022-07-25T19:17:11.262Z [INFO]: info - Compiled successfully info - Collecting page data... 2022-07-25T19:17:13.242Z [WARNING]: Duplicate atom key "currentUserFetch". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:13.243Z [WARNING]: Duplicate atom key "currentUserState". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:13.244Z [WARNING]: Duplicate atom key "currentUserStatewithFallback". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:14.419Z [WARNING]: Duplicate atom key "currentUserFetch". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:14.422Z [WARNING]: Duplicate atom key "currentUserState". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:14.422Z [WARNING]: Duplicate atom key "currentUserStatewithFallback". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:14.425Z [WARNING]: Duplicate atom key "projectIdState". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:14.426Z [WARNING]: Duplicate atom key "projectSlugState". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:14.426Z [WARNING]: Duplicate atom key "projectFetch". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:14.428Z [WARNING]: Duplicate atom key "projectState". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement. 2022-07-25T19:17:14.507Z [WARNING]: > Build error occurred 2022-07-25T19:17:14.509Z [WARNING]: Error: Build optimization failed: found pages without a React Component as default export in pages/privacy pages/blog pages/manifesto pages/blog/[pageId] pages/legal See https://nextjs.org/docs/messages/page-without-valid-component for more info. at /codebuild/output/src959537153/src/homeofopensource/node_modules/next/dist/build/index.js:674:19 at async Span.traceAsyncFn (/codebuild/output/src959537153/src/homeofopensource/node_modules/next/dist/telemetry/trace/trace.js:60:20) at async Object.build [as default] (/codebuild/output/src959537153/src/homeofopensource/node_modules/next/dist/build/index.js:77:25) 2022-07-25T19:17:14.618Z [WARNING]: error Command failed with exit code 1. 2022-07-25T19:17:14.618Z [INFO]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 2022-07-25T19:17:14.623Z [ERROR]: !!! Build failed 2022-07-25T19:17:14.623Z [ERROR]: !!! Non-Zero Exit Code detected 2022-07-25T19:17:14.623Z [INFO]: # Starting environment caching... 2022-07-25T19:17:14.624Z [INFO]: # Uploading environment cache artifact... 2022-07-25T19:17:14.702Z [INFO]: # Environment caching completed Terminating logging...

NilsJacobsen commented 2 years ago

@hloriana I tried it on netlify and it worked instantly. But I really wanna stay with amplify. Is it possible that my react-notion-x renderer needs some additional setup or is not support on amplify?

I used something like that for the getStaticProps: https://github.com/NotionX/react-notion-x/tree/master/examples/minimal

ghost commented 2 years ago

@NilsJacobsen It looks like devs run into this error Build optimization failed: found pages without a React Component as default export on other platforms when there's an issue installing a package so it's a bit misleading. In this case, ESLint is not installed. Can you try running yarn add --dev eslint and see if this resolves the error?

NilsJacobsen commented 2 years ago

Hi @hloriana, eslint is already in my dev dependencies.

I also tried this, but it did not help. https://nextjs.org/docs/api-reference/next.config.js/ignoring-eslint

Then I downgraded the aslant version to 7.23, because I read about an issue with nextjs and the latest eslint. https://github.com/vercel/next.js/issues/29770 That removed the aslant error. Now there's only a eslint waring, but still the same other error.

2022-07-26T13:22:10.992Z [INFO]: $ next build
2022-07-26T13:22:11.688Z [INFO]: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
2022-07-26T13:22:11.801Z [INFO]: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
2022-07-26T13:22:11.813Z [INFO]: Attention: Next.js now collects completely anonymous telemetry regarding usage.
2022-07-26T13:22:11.814Z [INFO]: This information is used to shape Next.js' roadmap and prioritize features.
                                 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
                                 https://nextjs.org/telemetry
2022-07-26T13:22:11.846Z [INFO]: info  - Checking validity of types...
2022-07-26T13:22:29.805Z [WARNING]: warn  - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config
2022-07-26T13:22:30.322Z [INFO]: ./src/pages/__workspace/[slug]/ideas/[id]/index.tsx
                                 21:28  Warning: 'error' is assigned a value but never used.  @typescript-eslint/no-unused-vars
                                 35:6  Warning: React Hook useEffect has a missing dependency: 'idea'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
                                 ./src/pages/__workspace/[slug]/index.tsx
                                 7:10  Warning: 'ProjectRole' is defined but never used.  @typescript-eslint/no-unused-vars
                                 41:6  Warning: React Hook useEffect has a missing dependency: 'updateUser'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
                                 54:11  Warning: 'userRole' is assigned a value but never used.  @typescript-eslint/no-unused-vars
                                 ./src/pages/__workspace/[slug]/settings.tsx
                                 6:10  Warning: 'ProjectRole' is defined but never used.  @typescript-eslint/no-unused-vars
                                 42:11  Warning: 'userRole' is assigned a value but never used.  @typescript-eslint/no-unused-vars
                                 ./src/pages/api/aws/index.ts
                                 9:17  Warning: 'req' is defined but never used.  @typescript-eslint/no-unused-vars
                                 9:22  Warning: 'res' is defined but never used.  @typescript-eslint/no-unused-vars
                                 ./src/pages/api/invitations/accept.ts
                                 3:8  Warning: 'prisma' is defined but never used.  @typescript-eslint/no-unused-vars
                                 ./src/pages/api/mailchimp/subscribe.ts
                                 1:10  Warning: 'errorMonitor' is defined but never used.  @typescript-eslint/no-unused-vars
                                 ./src/pages/auth/verify-request.tsx
                                 5:10  Warning: 'useGetCurrentUserQuery' is defined but never used.  @typescript-eslint/no-unused-vars
                                 ./src/pages/index.tsx
                                 9:8  Warning: 'LoadingPage' is defined but never used.  @typescript-eslint/no-unused-vars
                                 13:10  Warning: 'RecoilRoot' is defined but never used.  @typescript-eslint/no-unused-vars
                                 info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
2022-07-26T13:22:30.322Z [INFO]: info  - Creating an optimized production build...
2022-07-26T13:23:06.305Z [INFO]: info  - Compiled successfully
2022-07-26T13:23:06.307Z [INFO]: info  - Collecting page data...
2022-07-26T13:23:08.331Z [WARNING]: Duplicate atom key "currentUserFetch". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
2022-07-26T13:23:08.331Z [WARNING]: Duplicate atom key "currentUserState". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
                                    Duplicate atom key "currentUserState__withFallback". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
2022-07-26T13:23:09.436Z [WARNING]: Duplicate atom key "currentUserFetch". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
2022-07-26T13:23:09.438Z [WARNING]: Duplicate atom key "currentUserState". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
                                    Duplicate atom key "currentUserState__withFallback". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
                                    Duplicate atom key "projectIdState". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
                                    Duplicate atom key "projectSlugState". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
                                    Duplicate atom key "projectFetch". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
                                    Duplicate atom key "projectState". This is a FATAL ERROR in
                                    production. But it is safe to ignore this warning if it occurred because of
                                    hot module replacement.
2022-07-26T13:23:09.512Z [WARNING]: > Build error occurred
                                    Error: Build optimization failed: found pages without a React Component as default export in
                                    pages/legal
                                    pages/manifesto
                                    pages/privacy
                                    pages/blog
                                    pages/blog/[pageId]
                                    See https://nextjs.org/docs/messages/page-without-valid-component for more info.
                                    at /codebuild/output/src830895439/src/homeofopensource/node_modules/next/dist/build/index.js:674:19
                                    at async Span.traceAsyncFn (/codebuild/output/src830895439/src/homeofopensource/node_modules/next/dist/telemetry/trace/trace.js:60:20)
                                    at async Object.build [as default] (/codebuild/output/src830895439/src/homeofopensource/node_modules/next/dist/build/index.js:77:25)
2022-07-26T13:23:09.636Z [WARNING]: error Command failed with exit code 1.
2022-07-26T13:23:09.637Z [INFO]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2022-07-26T13:23:09.642Z [ERROR]: !!! Build failed
2022-07-26T13:23:09.642Z [ERROR]: !!! Non-Zero Exit Code detected
2022-07-26T13:23:09.642Z [INFO]: # Starting environment caching...
2022-07-26T13:23:09.642Z [INFO]: # Uploading environment cache artifact...
2022-07-26T13:23:09.726Z [INFO]: # Environment caching completed
Terminating logging...
NilsJacobsen commented 2 years ago

@hloriana As long as aslant only throws a warning it shouldn't stop the build process right? Since eslint wasn't the problem, do you have another debugging strategy that we could choose? Thanks for the help so far:)