Skip to content
>_VibeUnstuck

@prisma/client did not initialize yet

Last verified:

The fix

@prisma/client did not initialize yet. Run prisma generate so the client matches the schema. Generate does not migrate. Restart after it succeeds.

  1. 1

    Generate the client

    From the folder that contains schema.prisma, run generate. Commit the schema. Do not commit node_modules or the generated client if it lives inside node_modules.

    npx prisma generate
  2. 2

    Generate on every install

    Add a postinstall script so Vercel and any clean install build the client. If the host installs with --ignore-scripts, put prisma generate in the build command before next build instead.

    {
      "scripts": {
        "postinstall": "prisma generate",
        "build": "prisma generate && next build"
      }
    }
  3. 3

    Point the schema at the right file

    If the schema is not at prisma/schema.prisma, generate needs --schema or the prisma.schema entry in package.json. A second schema the model created in a subfolder will not be the one the import uses.

  4. 4

    Separate generate from migrate

    Do not run prisma migrate dev on Vercel. That command is interactive and can reset a database. Use prisma migrate deploy in a release step when migrations should ship. A connection error after generate succeeds is the database URL, not this error. See the Postgres page.

Why it happens

@prisma/client is a small package until prisma generate reads schema.prisma and writes the client. A fresh install, a schema edit, or a CI machine that skipped install scripts will import a client that is not there yet.

prisma generate does not talk to the database and does not apply migrations. migrate dev is for your laptop. Production and Vercel should run migrate deploy only when you intend to change the database, and generate has to happen before next build imports the client.

The next error you'll probably hit

Once this is fixed, the usual follow-up is Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x". The Vercel function is looking for the Linux query-engine binary and that file is not in the deployment. Generate ran for another OS, or the binary was stripped from the bundle.

Prompt to paste back into your AI tool

Paste this above the error.

Importing @prisma/client fails with: did not initialize yet. Please run prisma generate. Or: Cannot find module '.prisma/client/default'.

Do not mock Prisma. Do not run migrate dev against production.

1. Run prisma generate against the schema this app imports.
2. Add postinstall or a build step so generate runs before next build on a clean install.
3. Leave migrations alone unless I ask. If the next error is a connection failure, stop and say it is the database URL.
4. Do not edit the schema to silence the import.

Common questions

+Generate succeeded and the import still fails. Why?

The running process started before generate, or there are two copies of @prisma/client (a nested node_modules). Restart the dev server. If a custom output path is set in the schema, import that path instead of @prisma/client.

+Does generate apply my migration?

No. It only writes the client. The database changes when you run migrate deploy or migrate dev.

Related errors