Update for June 2024

See original solution below.
There are two options today that would work without disabling Yarn Plug'n'Play.

  1. Custom Prisma Output Directory
    Prisma allows configuration of where it places the files of the generated client. To do so, set the output property in the generator block. It is best to also set the same path in your .gitignore.
generator client {
  provider = "prisma-client-js"
  output   = "../src/generated/client"
}

Full Docs: https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path

  1. Yarn PnPify
    This acts as a middleman to redirect Prisma's output. See the comment from Moses Gamelli below for instructions.

After having tested a number of different things, I believe I have found a solution.

The Problem

The problem lies in how Yarn is resolving imports. Prisma CLI generates the client (by default) to node_modules/.prisma. Even when nodeLinker is set to node-modules, Yarn tries to resolve this import to .yarn/unplugged/<folder-name>, where the generated client does not exist.

The Solution

In order to fix this resolution problem, we have to create a custom resolution for the .prisma folder. This assumes that you do not have a custom output path.

# .yarnrc.yml

nodeLinker: node-modules

packageExtensions:
  "@prisma/client@*":
    dependencies:
      ".prisma": 'link:See "resolution" field of package.json'
# package.json

{
  ...
  "resolutions": {
     ".prisma": "link:node-modules/.prisma"
  }
}

Credit to this user on Github

Answer from Henrik VT on Stack Overflow
🌐
Prisma
prisma.io › home › generating prisma client › generating prisma client › generating prisma client › generating prisma client
Generating Prisma Client | Prisma Documentation
generator client { provider = "prisma-client" output = "./generated" } Run the following command whenever you add models, change fields, or update generator settings: bun · pnpm · yarn · npm · bunx prisma generate · If you want the CLI-specific options such as --watch or --generator, see the prisma generate command reference.
Top answer
1 of 2
5

Update for June 2024

See original solution below.
There are two options today that would work without disabling Yarn Plug'n'Play.

  1. Custom Prisma Output Directory
    Prisma allows configuration of where it places the files of the generated client. To do so, set the output property in the generator block. It is best to also set the same path in your .gitignore.
generator client {
  provider = "prisma-client-js"
  output   = "../src/generated/client"
}

Full Docs: https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path

  1. Yarn PnPify
    This acts as a middleman to redirect Prisma's output. See the comment from Moses Gamelli below for instructions.

After having tested a number of different things, I believe I have found a solution.

The Problem

The problem lies in how Yarn is resolving imports. Prisma CLI generates the client (by default) to node_modules/.prisma. Even when nodeLinker is set to node-modules, Yarn tries to resolve this import to .yarn/unplugged/<folder-name>, where the generated client does not exist.

The Solution

In order to fix this resolution problem, we have to create a custom resolution for the .prisma folder. This assumes that you do not have a custom output path.

# .yarnrc.yml

nodeLinker: node-modules

packageExtensions:
  "@prisma/client@*":
    dependencies:
      ".prisma": 'link:See "resolution" field of package.json'
# package.json

{
  ...
  "resolutions": {
     ".prisma": "link:node-modules/.prisma"
  }
}

Credit to this user on Github

2 of 2
2

If you're using yarn with pnp enabled:

  1. Install @yarnpkg/pnpify to dev dependencies
  2. Prepend yarn pnpify with any prisma command e.g yarn pnpify prisma generate
  3. Consider using a custom output path in your prisma schema
🌐
Prisma
prisma.io › home › introduction to prisma client › introduction to prisma client › introduction to prisma client › introduction to prisma client
Introduction to Prisma Client | Prisma Documentation
March 24, 2023 - yarn · npm · bunx prisma generate · This will create a generated directory based on where you set the output to in the Prisma Schema. Any time your import Prisma Client, it will need to come from this generated client API.
🌐
GitHub
github.com › prisma › prisma › issues › 17084
Cannot run `generate` script if prisma was installed with yarn v3 Plug'n'Play · Issue #17084 · prisma/prisma
January 1, 2023 - Please install them with yarn add -D prisma and yarn add @prisma/client, and rerun yarn prisma generate 🙏.
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 8765
prisma generate fails in yarn2 / yarn3 workspaces #8765
August 16, 2021 - yarn prisma generate Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma npm ERR! code EUNSUPPORTEDPROTOCOL npm ERR! Unsupported URL Type "workspace:": workspace:core-api-plugins/article-import-edeka npm ERR! A complete log of this run can be found in: npm ERR!
Author   prisma
🌐
Prisma
prisma.io › home › generate › generate
prisma generate | Generate Prisma Client & Artifacts | Prisma Documentation
Multiple generators: bun · pnpm · yarn · npm · bunx prisma generate --generator client --generator zod_schemas · The prisma-client generator creates a customized client for working with your database.
🌐
GitHub
github.com › prisma › prisma › issues › 22534
`yarn prisma generate` has stopped updating types when `prisma.schema` changes. · Issue #22534 · prisma/prisma
January 2, 2024 - Without one of those two conditions being present yarn isn't recompiling/regenerating the node_modules/.prisma/client bundle when running prisma generate resulting in the old types continuing to be used.
Author   prisma
Find elsewhere
🌐
Prisma
prisma.io › home › generators › generators › generators › generators
Generators (Reference) | Prisma Documentation
Generate Prisma Client by running: bun · pnpm · yarn · npm · bunx prisma generate · This generates the code for Prisma Client (including the query engine binary) into the specified output folder.
🌐
Yarn
classic.yarnpkg.com › en › package › @prisma › sdk
prisma/sdk
Important: This documentation covers Yarn 1 (Classic).
🌐
GitHub
github.com › prisma › prisma-client-js › issues › 819
Yarn 2 and Prisma Client break · Issue #819 · prisma/prisma-client-js
September 8, 2020 - When using Yarn 2 with Prisma, yarn prisma generate creates node_modules/.prisma/client but Yarn 2 uses PnP which removes node_modules in favor of their own cache stored in .yarn/cache. Prisma Client however generated the new client inside of node_modules.
Author   prisma
🌐
Yarn
yarnpkg.com › package
Yarn
Cannot read properties of null (reading 'startsWith')
🌐
Auth.js
authjs.dev › getting-started › adapters › prisma
Auth.js | Prisma
June 11, 2026 - yarn prisma migrate dev · bunx prisma migrate dev · Note that you will need to specify your database connection string in the environment variable DATABASE_URL. You can do this by setting it in a .env file at the root of your project. prisma migrate dev will also generate the Prisma client, but if you need to generate it again manually you can run the following command.
🌐
DEV Community
dev.to › this-is-learning › its-prisma-time-setup-ei7
It's Prisma Time - Setup - DEV Community
December 16, 2021 - The schema file is the single source of truth when we use Prisma, in this file, we add all the entities and all their relations. From this file, Prisma can generate our typescript types related to the entities and it can create our migration scripts to upgrade the schema of our source.
🌐
Answer Overflow
answeroverflow.com › m › 1402269838340264078
Can't prisma generate
August 5, 2025 - D:\Blog>yarn prisma generate Environment variables loaded from .env Prisma schema loaded from prisma\schema.prisma Error: Could not resolve prisma and @prisma/client in the current project. Please install them with yarn add prisma -D and yarn add @prisma/client, and rerun yarn dlx "prisma generate" ...