Multiple prisma with nx workspaces and nestjs
See original GitHub issueBug description
I have tried nx workspace with nestjs and prisma which outputs to node_modules (default setup) and it works, but using multiple prismas with custom directory output fails.
Running nx build
shows warnings
Running nx serve
shows errors
I have this kind of setup with nestjs and many prisma (need to access different databases) using the default structure (no monorepo) and it works without problems. I think the problem resides with webpack and the binaries from prisma, but I don’t know how to solve it.
nx structure
How to reproduce
- Clone repository https://github.com/ionut-gheorghe/nx-multi-prisma.git
- Run
npm install
- Run
npm run prisma1:generate
script - Run
npm run prisma2:generate
script - Run
nx serve
Expected behavior
To run without errors
Prisma information
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
generator client {
provider = "prisma-client-js"
output = "../generated"
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
}
Environment & setup
- OS: Windows 10
- Database: Sql Lite
- Node.js version: 14 Lts
Prisma Version
2.23.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:23 (13 by maintainers)
Top Results From Across the Web
Applying Full Stack Type Safety with Angular, Nest, Nx & Prisma
Let's add a NestJS project to the workspace. To add our NestJS project, we first need to install the official NestJS plugin for...
Read more >Add Prisma to a NestJS API in a Nx Workspace -BLS003
In this live video you will learn How to Add Prisma to a NestJS API in a Nx Workspace. We are Building the...
Read more >Building an Nx Prisma Generator - Sabin Adams - Hashnode
Learn how to automate the process of creating prisma instances in your Nx monorepo. Then give it a test by using the client...
Read more >Prisma | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines ...
Read more >Nx — Model With Prisma - Medium
In this article I detail how I use Prisma with Nx to maintain my data models. ... you have played with Nx a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi all, I found a temporary solution for this case:
For schema file:
and then, in nest module file, you can import client like that
If you find a better solution, remember to be brave and share it like I did. lol 😄
@ionut-gheorghe I’m having the same problem here with a project using Nx and Prisma.
My use-case is to have a monorepo using Nx with multiple micro services. I would like to use a separate Prisma client with its own schema in every micro service.