You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Setting up Prisma in a hoisted environment (pnpm, npm workspaces) #1910
changed the title [-]Setting up Prisma in a hosted environment (pnpm, npm workspaces)[/-][+]Setting up Prisma in a hoisted environment (pnpm, npm workspaces)[/+]on Jun 22, 2021
Generation
This ensures that the client is generated in the sub-project's node_modules folder. Otherwise it would get generated in the root / hoisted node_modules (for both app1 & app2) and two clients could overwrite each other.
Imports
Because @prisma/client is hoisted in the root folder and reused by app1 & app2 (symlinked in their respective node_modules), we cannot resolve types or any nearby generated client. Thus it has to be imported this way.
The main purpose of this doc is to help users that would like to generate more than one client while working in a hoisted environment (in this case, a pnpm workspace).
Yes this is something a lot of people who use multi-service monorepos actually run into. It's not obvious why the Prisma Clietn package gets deduplicated by some package managers, that in turn makes that you cannot output/generate multiple clients. There's one thing that I would change from my example though: the custom output into node modules, I'd just make it a custom output in the project folder and use a gitignore not to include the files.
👋 we're cleaning up our backlog of issues and are closing everything older than two years. If you still feel that this issue is relevant, please feel free to re-open and our team will take a look. Thank you!
Activity
[-]Setting up Prisma in a hosted environment (pnpm, npm workspaces)[/-][+]Setting up Prisma in a hoisted environment (pnpm, npm workspaces)[/+]millsp commentedon Jun 22, 2021
For some more context, here's how to set up a project with pnpm https://github.com/millsp/prisma-pnpm-workspace. There are two important things:
This ensures that the client is generated in the sub-project's
node_modulesfolder. Otherwise it would get generated in the root / hoistednode_modules(for bothapp1&app2) and two clients could overwrite each other.Because
@prisma/clientis hoisted in the root folder and reused byapp1&app2(symlinked in their respectivenode_modules), we cannot resolve types or any nearby generated client. Thus it has to be imported this way.The main purpose of this doc is to help users that would like to generate more than one client while working in a hoisted environment (in this case, a
pnpmworkspace).janpio commentedon Jun 22, 2021
Meaning: If you use pnpm or similar, and just have 1 generated Client, you can do what exactly?
molebox commentedon Aug 10, 2021
This should be added to the Development environment section
jharrell commentedon Aug 14, 2023
@millsp is this still the case?
millsp commentedon Aug 14, 2023
Yes this is something a lot of people who use multi-service monorepos actually run into. It's not obvious why the Prisma Clietn package gets deduplicated by some package managers, that in turn makes that you cannot output/generate multiple clients. There's one thing that I would change from my example though: the custom output into node modules, I'd just make it a custom output in the project folder and use a gitignore not to include the files.
jharrell commentedon Nov 21, 2024
👋 we're cleaning up our backlog of issues and are closing everything older than two years. If you still feel that this issue is relevant, please feel free to re-open and our team will take a look. Thank you!