Skip to content

Add postinstall and vercel-build scripts to generate Prisma Client#3

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/add-prisma-generate-scripts
Draft

Add postinstall and vercel-build scripts to generate Prisma Client#3
Copilot wants to merge 4 commits into
mainfrom
copilot/add-prisma-generate-scripts

Conversation

Copilot AI commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Vercel builds fail with "@prisma/client did not initialize yet" because the Prisma Client isn't generated before Next.js imports it during build-time page data collection.

Changes

  • postinstall: Runs prisma generate automatically after npm install, ensuring the client exists before any build step
  • vercel-build: Explicit build command that runs prisma generate && next build for redundancy in Vercel's deployment pipeline
"scripts": {
  "postinstall": "prisma generate",
  "vercel-build": "prisma generate && next build"
}

The postinstall hook triggers during Vercel's install phase, while vercel-build provides a fallback that Vercel can explicitly invoke.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkpoint.prisma.io
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/SolUPI-V2/SolUPI-V2/node_modules/prisma/build/child {"product":"prisma","version":"6.19.0","cli_install_type":"local","information":"","local_timestamp":"2025-11-17T09:10:45Z","project_hash":"01344839","cli_path":"/home/REDACTED/work/SolUPI-V2/SolUPI-V2/node_modules/.bin/prisma","cli_path_hash":"6b31b5a6","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate","schema_providers":["postgresql"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-6b31b5a6","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/SolUPI-V2/SolUPI-V2/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true} (dns block)
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/SolUPI-V2/SolUPI-V2/node_modules/prisma/build/child {"product":"prisma","version":"6.19.0","cli_install_type":"local","information":"","local_timestamp":"2025-11-17T09:10:54Z","project_hash":"01344839","cli_path":"/home/REDACTED/work/SolUPI-V2/SolUPI-V2/node_modules/.bin/prisma","cli_path_hash":"6b31b5a6","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate","schema_providers":["postgresql"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-6b31b5a6","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/SolUPI-V2/SolUPI-V2/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true} (dns block)
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/SolUPI-V2/SolUPI-V2/node_modules/prisma/build/child {"product":"prisma","version":"6.19.0","cli_install_type":"local","information":"","local_timestamp":"2025-11-17T09:12:43Z","project_hash":"01344839","cli_path":"/home/REDACTED/work/SolUPI-V2/SolUPI-V2/node_modules/.bin/prisma","cli_path_hash":"6b31b5a6","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate --postinstall \"UNABLE_TO_FIND_POSTINSTALL_TRIGGER__ENVAR_MISSING\"","schema_providers":["postgresql"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-6b31b5a6","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/SolUPI-V2/SolUPI-V2/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true} (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Background:
During Vercel builds, Next.js fails with the error: "@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again." This happens because the Prisma Client isn't generated in the build environment before Next imports it while collecting page data.

Goal:
Create a small change that guarantees Prisma Client is generated during the Vercel build/install step so that @prisma/client is available at build time and Next.js can complete its build.

Required changes:

  1. Modify package.json in the repository root to add a postinstall script that runs "prisma generate" and add a vercel-build script that runs "prisma generate && next build". Keep existing scripts and dependencies intact.

Exact file change to apply (package.json):

  • Add two new scripts under "scripts":
    "postinstall": "prisma generate",
    "vercel-build": "prisma generate && next build"

Rationale:

  • Vercel runs "npm install" which triggers the "postinstall" lifecycle script. Running "prisma generate" there ensures the generated Prisma Client is present before Next.js runs its build.
  • Adding "vercel-build" provides an explicit build command for Vercel that also runs "prisma generate" before "next build" for redundancy.

Testing and verification:

  • After the PR is created and merged, Vercel deployments for the branch should show "prisma generate" running during install/build. The previous build error "@prisma/client did not initialize yet" should be resolved.
  • Locally, the commands to verify are:
    npm install
    npm run build
    (or simply) npm run postinstall && npm run build

Notes:

  • @prisma/client is already listed in dependencies in package.json; no dependency moves are required.
  • If the user prefers, the PR can also include an optional prisma/schema.prisma change to add binaryTargets, but that change is not required now and is left out to minimize risk.

Please create a pull request that updates package.json with the two new scripts and a commit message: "ci: generate prisma client during install/build (postinstall & vercel-build)".

This pull request was created as a result of the following prompt from Copilot chat.

Background:
During Vercel builds, Next.js fails with the error: "@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again." This happens because the Prisma Client isn't generated in the build environment before Next imports it while collecting page data.

Goal:
Create a small change that guarantees Prisma Client is generated during the Vercel build/install step so that @prisma/client is available at build time and Next.js can complete its build.

Required changes:

  1. Modify package.json in the repository root to add a postinstall script that runs "prisma generate" and add a vercel-build script that runs "prisma generate && next build". Keep existing scripts and dependencies intact.

Exact file change to apply (package.json):

  • Add two new scripts under "scripts":
    "postinstall": "prisma generate",
    "vercel-build": "prisma generate && next build"

Rationale:

  • Vercel runs "npm install" which triggers the "postinstall" lifecycle script. Running "prisma generate" there ensures the generated Prisma Client is present before Next.js runs its build.
  • Adding "vercel-build" provides an explicit build command for Vercel that also runs "prisma generate" before "next build" for redundancy.

Testing and verification:

  • After the PR is created and merged, Vercel deployments for the branch should show "prisma generate" running during install/build. The previous build error "@prisma/client did not initialize yet" should be resolved.
  • Locally, the commands to verify are:
    npm install
    npm run build
    (or simply) npm run postinstall && npm run build

Notes:

  • @prisma/client is already listed in dependencies in package.json; no dependency moves are required.
  • If the user prefers, the PR can also include an optional prisma/schema.prisma change to add binaryTargets, but that change is not required now and is left out to minimize risk.

Please create a pull request that updates package.json with the two new scripts and a commit message: "ci: generate prisma client during install/build (postinstall & vercel-build)".


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel

vercel Bot commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sol-upi-v2 Ready Ready Preview Comment Nov 17, 2025 9:12am

…-build)

Co-authored-by: naveenkumar29052006 <72962565+naveenkumar29052006@users.noreply.github.com>
Copilot AI changed the title [WIP] Add postinstall and vercel-build scripts for Prisma Client generation Add postinstall and vercel-build scripts to generate Prisma Client Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants