Open NilsJacobsen opened 2 years ago
Hi @NilsJacobsen 👋🏽 can you also provide your next.config.js
file as well?
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: "/",
},
];
},
};
@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"
};
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...
@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
@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?
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...
@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:)
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: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:
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
Build Settings
Additional information
No response