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 🙏
How do I generate a prisma client in my current project when the schema file is in another project?
`prisma generate` fails in yarn2 / yarn3 workspaces
`prisma generate` generates to incorrect location when using `npm link` or `yarn link`
A Guide for building community prisma generators
Update for June 2024
See original solution below.
There are two options today that would work without disabling Yarn Plug'n'Play.
- Custom Prisma Output Directory
Prisma allows configuration of where it places the files of the generated client. To do so, set theoutputproperty in thegeneratorblock. 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
- 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
If you're using yarn with pnp enabled:
- Install
@yarnpkg/pnpifyto dev dependencies - Prepend
yarn pnpifywith any prisma command e.gyarn pnpify prisma generate - Consider using a custom output path in your prisma schema
» npm install prisma
That's what I did in package.json file (It was a deploy a Next app on Versel) I just added generate command to the build script:
"scripts": {
"dev": "next dev",
"build": "prisma generate && next build",
"start": "next start",
"lint": "next lint"
},
Not sure if it is a correct way, though..
There's no need to run the prisma generate command that is executed on installation of the @prisma/client.
EDIT: https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/generating-prisma-client