Error: Failed to collect page data for /api/reservations
Does this work locally?
Alternatively I noticed a few other things:
3:07:21 PM: 69:5 Warning: React Hook useMemo has an unnecessary dependency: ‘location’. Either exclude it or remove the dependency array. react-hooks/exhaustive-deps
3:07:21 PM: ./app/components/modals/SearchModal.tsx
3:07:21 PM: 41:9 Warning: React Hook useMemo has an unnecessary dependency: ‘location’. Either exclude it or remove the dependency array. react-hooks/exhaustive-deps
3:07:21 PM: 87:8 Warning: React Hook useCallback has missing dependencies: ‘location?.value’ and ‘router’. Either include them or remove the dependency array. react-hooks/exhaustive-deps
Adding CI=npm run build to your netlify.toml, or as your build command should skip these. Example:
[build]
command = "CI= npm run build"
One last thing I noticed that’s a bit odd, and I did some researching on, but not entirely confident on is this bit:
3:07:24 PM: PrismaClientInitializationError: Prisma has detected that this project was built on Netlify CI, which caches dependencies. This leads to an outdated Prisma Client because Prisma’s auto-generation isn’t triggered. To fix this, make sure to run the `prisma generate` command during the build process.
It looks like the error is telling you to add prisma generate to your build command, so the Prisma client can work properly. Something like this should do the trick:
[build]
command = "prisma generate && npm run build"
However, I get a new error. Here is the build log:
9:12:02 PM: Netlify Build
9:12:02 PM: ────────────────────────────────────────────────────────────────
9:12:02 PM:
9:12:02 PM: ❯ Version
9:12:02 PM: @netlify/build 29.46.5
9:12:02 PM:
9:12:02 PM: ❯ Flags
9:12:02 PM: baseRelDir: true
9:12:02 PM: buildId: 6667ce665e2a840008c39973
9:12:02 PM: deployId: 6667ce665e2a840008c39975
9:12:02 PM:
9:12:02 PM: ❯ Current directory
9:12:02 PM: /opt/build/repo
9:12:02 PM:
9:12:02 PM: ❯ Config file
9:12:02 PM: /opt/build/repo/netlify.toml
9:12:02 PM:
9:12:02 PM: ❯ Context
9:12:02 PM: production
9:12:03 PM:
9:12:03 PM: ❯ Using Next.js Runtime - v5.3.2
9:12:04 PM: No Next.js cache to restore
9:12:04 PM:
9:12:04 PM: build.command from netlify.toml
9:12:04 PM: ────────────────────────────────────────────────────────────────
9:12:04 PM:
9:12:04 PM: $ prisma generate && npm run build
9:12:05 PM: Environment variables loaded from .env
9:12:05 PM: Prisma schema loaded from prisma/schema.prisma
9:12:05 PM: ✔ Generated Prisma Client (v5.14.0) to ./node_modules/@prisma/client in 72ms
9:12:05 PM: Start using Prisma Client in Node.js (See: https://pris.ly/d/client)
9:12:05 PM: ```
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
9:12:05 PM: or start using Prisma Client at the edge (See: What is Accelerate | Prisma Documentation)
9:12:05 PM: ```
import { PrismaClient } from ‘@prisma/client/edge’
const prisma = new PrismaClient()
9:12:05 PM: See other ways of importing Prisma Client: http://pris.ly/d/importing-client
9:12:05 PM: ┌─────────────────────────────────────────────────────────────┐
9:12:05 PM: │ Deploying your app to serverless or edge functions? │
9:12:05 PM: │ Try Prisma Accelerate for connection pooling and caching. │
9:12:05 PM: │ https://pris.ly/cli/--accelerate │
9:12:05 PM: └─────────────────────────────────────────────────────────────┘
9:12:06 PM: > airbnb-clone-2@0.1.0 build
9:12:06 PM: > next build
9:12:06 PM: ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
9:12:06 PM: ▲ Next.js 14.1.4
9:12:06 PM: - Environments: .env
9:12:06 PM: Creating an optimized production build ...
9:12:32 PM: ✓ Compiled successfully
9:12:32 PM: Linting and checking validity of types ...
9:12:34 PM: ./app/components/modals/RentModal.tsx
9:12:34 PM: 69:5 Warning: React Hook useMemo has an unnecessary dependency: 'location'. Either exclude it or remove the dependency array. react-hooks/exhaustive-deps
9:12:34 PM: ./app/components/modals/SearchModal.tsx
9:12:34 PM: 41:9 Warning: React Hook useMemo has an unnecessary dependency: 'location'. Either exclude it or remove the dependency array. react-hooks/exhaustive-deps
9:12:34 PM: 87:8 Warning: React Hook useCallback has missing dependencies: 'location?.value' and 'router'. Either include them or remove the dependency array. react-hooks/exhaustive-deps
9:12:34 PM: info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
9:12:35 PM: Collecting page data ...
9:12:38 PM: Generating static pages (0/12) ...
9:12:39 PM: Generating static pages (3/12)
9:12:39 PM: Error: Error: Dynamic server usage: Page couldn't be rendered statically because it used `searchParams.userId`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
at i (/opt/build/repo/.next/server/app/page.js:1:6294)
9:12:39 PM: at u (/opt/build/repo/.next/server/app/page.js:1:7040)
9:12:39 PM: at em (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:131205)
9:12:39 PM: at /opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:142906
9:12:39 PM: at Array.toJSON (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:146484)
9:12:39 PM: at stringify (<anonymous>)
9:12:39 PM: at eR (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:134868)
9:12:39 PM: at eP (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:135311)
9:12:39 PM: at AsyncLocalStorage.run (node:async_hooks:338:14)
9:12:39 PM: at Timeout._onTimeout (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:146936)
9:12:39 PM: Error: Error: Dynamic server usage: Page couldn't be rendered statically because it used `searchParams.userId`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
at i (/opt/build/repo/.next/server/app/page.js:1:6294)
9:12:39 PM: at u (/opt/build/repo/.next/server/app/page.js:1:7040)
9:12:39 PM: at em (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:131205)
9:12:39 PM: at /opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:142906
9:12:39 PM: at Array.toJSON (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:146484)
9:12:39 PM: at stringify (<anonymous>)
9:12:39 PM: at eR (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:134868)
9:12:39 PM: at eP (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:135311)
9:12:39 PM: at Timeout._onTimeout (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:132091)
9:12:39 PM: at listOnTimeout (node:internal/timers:569:17)
9:12:39 PM: Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
9:12:39 PM: Error: Error: Dynamic server usage: Page couldn't be rendered statically because it used `searchParams.userId`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
at i (/opt/build/repo/.next/server/app/page.js:1:6294)
9:12:39 PM: at u (/opt/build/repo/.next/server/app/page.js:1:7040)
9:12:39 PM: at em (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:131205)
9:12:39 PM: at /opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:142906
9:12:39 PM: at Array.toJSON (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:146484)
9:12:39 PM: at stringify (<anonymous>)
9:12:39 PM: at eR (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:134868)
9:12:39 PM: at eP (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:135311)
9:12:39 PM: at AsyncLocalStorage.run (node:async_hooks:338:14)
9:12:39 PM: at Timeout._onTimeout (/opt/build/repo/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:146936)
9:12:39 PM: Generating static pages (6/12)
9:12:39 PM: Generating static pages (9/12)
9:12:39 PM: ✓ Generating static pages (12/12)
9:12:39 PM: > Export encountered errors on following paths:
9:12:39 PM: /page: /
9:12:39 PM:
9:12:39 PM: "build.command" failed
9:12:39 PM: ────────────────────────────────────────────────────────────────
9:12:39 PM:
9:12:39 PM: Error message
9:12:39 PM: Command failed with exit code 1: prisma generate && npm run build (https://ntl.fyi/exit-code-1)
9:12:39 PM:
9:12:39 PM: Error location
9:12:39 PM: In build.command from netlify.toml:
9:12:39 PM: prisma generate && npm run build
9:12:39 PM:
9:12:39 PM: Resolved config
9:12:39 PM: build:
9:12:39 PM: command: prisma generate && npm run build
9:12:39 PM: commandOrigin: config
9:12:39 PM: environment:
9:12:39 PM: - DATABASE_URL
9:12:39 PM: - GITHUB_ID
9:12:39 PM: - GITHUB_SECRET
9:12:39 PM: - GOOGLE_CLIENT_ID
9:12:39 PM: - GOOGLE_CLIENT_SECRET
9:12:39 PM: - ****
9:12:39 PM: - NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
9:12:39 PM: - PRISMA_TELEMETRY_INFORMATION
9:12:39 PM: publish: /opt/build/repo/.next
9:12:39 PM: publishOrigin: ui
9:12:39 PM: plugins:
9:12:39 PM: - inputs: {}
9:12:39 PM: origin: ui
9:12:39 PM: package: '@netlify/plugin-nextjs'
9:12:40 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:12:40 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:12:40 PM: Failing build: Failed to build site
9:12:40 PM: Finished processing build request in 1m10.666s
To clarify, we have to make the netlify.toml in our root directory ourselves, right? Also, to answer your question, this has been coded on my computer and I have used localhost for developing it. I have committed it to GitHub and then fed that to Netlify. I did not have my local server running.