1 year ago

#388137

test-img

Yuri van Geffen

"prisma generate" moves generated package outside of working directory

I have a setup where I want to share a Prisma schema file between different node packages within a mono-repo. The schema has multiple but these models are not exported to the client. The reason is because the local client is not actually updated when running prisma generate --schema=.... It updates another instance of the client, as can be seen in the output of the command:

$ npx prisma generate --schema=./../shared/prisma/prisma/schema.prisma
Prisma schema loaded from ../shared/prisma/prisma/schema.prisma

āœ” Generated Prisma Client (3.12.0 | library) to ./../shared/prisma/node_modules/@prisma/client in 199ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

Done in 2.66s.

In the local package directly under node_modules the types are nonsensical:

export declare const PrismaClient: any
...
export declare type PrismaClient = any
export declare const dmmf: any
export declare type dmmf = any
...

How do I make sure that the local copy of the client is updated? Is there something wrong in the way I approach this (is there a better way to share a Prisma schema between packages)?

Thanks in advance!

node.js

typescript

prisma

0 Answers

Your Answer

Accepted video resources