Hi @JoshuaPuello 👋

Thank you for raising this question.

Can you please try generating the types in the default location (of node_modules) by removing this output from the schema file

output   = "../dist/generated/client"

and export it like

export { PrismaClient } from '@prisma/client'

If this answers your question, it would be great if you could mark this Discussion as answered to indicate that it has been resolved.

Otherwise please let us know how else we can help you further or close the Discussion if it was resolved in some other way 🙏

Discussions

How do I generate a prisma client in my current project when the schema file is in another project?
Hi there, I struggle to find a way to make the question from the title work. This is a mono-repo setting. There is project A containing migrations and the schema.prisma file at the default location... More on github.com
🌐 github.com
3
1
December 9, 2023
`prisma generate` fails in yarn2 / yarn3 workspaces
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! More on github.com
🌐 github.com
19
August 16, 2021
`prisma generate` generates to incorrect location when using `npm link` or `yarn link`
Issue: When using npm link, the generate prisma client gets generate to the inner node_modules of the package containing the prisma schema. Example: I'm working on a project my-project that takes a dependency on prisma-schema which contains our schema.prisma. After running yarn link, running ... More on github.com
🌐 github.com
2
January 27, 2023
A Guide for building community prisma generators
Make a little CLI tool for people to use to setup all of the boilerplate needed to start developing a new prisma generator which will contain: Private yarn workspace for testing the generator. More on github.com
🌐 github.com
2
2
🌐
Prisma
prisma.io › home › generating prisma client › generating prisma client › generating prisma client › generating prisma client
Generating Prisma Client | Prisma Documentation
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 ...
🌐
GitHub
github.com › keonik › prisma-erd-generator
GitHub - keonik/prisma-erd-generator: Generate an ER Diagram based on your Prisma schema every time you run npx prisma generate · GitHub
npm i -D prisma-erd-generator @mermaid-js/mermaid-cli puppeteer # or yarn add -D prisma-erd-generator @mermaid-js/mermaid-cli puppeteer
Starred by 1K users
Forked by 62 users
Languages   TypeScript 91.2% | JavaScript 8.8%
🌐
GitHub
github.com › prisma › prisma › issues › 8765
prisma generate fails in yarn2 / yarn3 workspaces #8765
August 16, 2021 - clone this repo: https://github.com/v-morlock/prisma-yarn2-repro
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 17591
`prisma generate` generates to incorrect location when using `npm link` or `yarn link` · Issue #17591 · prisma/prisma
January 27, 2023 - Run yarn link prisma-schema from the project from step 2. ... datasource db { provider = "postgresql" url = env("DB_URL") } generator client { provider = "prisma-client-js" } model Record { id String @id }
Author   prisma
Find elsewhere
🌐
GitHub
github.com › prisma › prisma › issues › 19206
Unable to yarn prisma generate · Issue #19206 · prisma/prisma
May 11, 2023 - (Use --skip-generate to skip the generators) ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0000: └ Completed in 0s 378ms ➤ YN0000: ┌ Link step ➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental ➤ YN0000: └ Completed ➤ YN0000: Done with warnings in 0s 739ms ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0000: └ Completed in 0s 315ms ➤ YN0000: ┌ Link step ➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental ➤ YN0000: └ Completed ➤ YN0000: Done with warnings in 0s 653ms Error: Could not resolve @prisma/client despite the installation that we just tried. Please try to install it by hand with [object Promise] and rerun yarn dlx prisma generate 🙏.
Author   prisma
🌐
GitHub
github.com › mercen4ry0923 › prisma
GitHub - mercen4ry0923/prisma · GitHub
generator nestgraphql { provider = "node node_modules/prisma-nestjs-graphql" // for yarn monorepos // provider = "prisma-nestjs-graphql" output = "../src/@generated" } Run prisma generate · npx prisma generate · If your models have Decimal and Json types, you need install: npm install graphql-type-json prisma-graphql-type-decimal ·
Author   mercen4ry0923
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
🌐
npm
npmjs.com › package › prisma
prisma - npm
3 days ago - You can ask questions and initiate discussions about Prisma-related topics in the prisma repository on GitHub.
      » npm install prisma
    
Published   Jul 20, 2026
Version   7.9.0
🌐
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
🌐
Prisma
prisma.io › home › generate › generate
prisma generate | Generate Prisma Client & Artifacts | Prisma Documentation
yarn · npm · bunx prisma generate --generator client --generator zod_schemas · The prisma-client generator creates a customized client for working with your database. You can customize the output folder using the output field in the generator ...
🌐
GitHub
github.com › prisma › prisma › issues › 3208
Since v2.4 prisma generate no longer works in yarn workspaces · Issue #3208 · prisma/prisma
August 4, 2020 - domain/clientIssue in the "Client" domain: Prisma Client, Prisma Studio etc.Issue in the "Client" domain: Prisma Client, Prisma Studio etc.kind/improvementAn improvement to existing feature and code.An improvement to existing feature and code.topic: yarn workspaces ... Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check). ... The prisma types should be generated successfully.
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 7234
Could not resolve @prisma/client despite the installation that we just tried. · Issue #7234 · prisma/prisma
May 23, 2021 - One aspect of this project is that it's a multi-tenant yarn workspaces repo with a few different packages inside, but the root package includes prisma as a dependency and @prisma/client as a dev dependency (which I'm not sure why, I think it solved another similar issue a couple of months back) It's probably project specific, but just running generate triggers it.
Author   prisma
🌐
GitHub
github.com › prisma › prisma › discussions › 4038
yarn generate gets stuck on something · prisma/prisma · Discussion #4038
October 26, 2020 - Give feedback. ... It's due to ts-node transpiling. If you remove the generate:nexus part from this script, it should work: "generate": "npm -s run generate:prisma && npm -s run generate:nexus",
Author   prisma