:alphabet-yellow-question: *NextJS app in monorepo...
# orm-help
r
alphabet yellow question NextJS app in monorepo is unable to locate
schema.prisma
(generated in a separate package in the same monorepo) Question What is the best way for me to setup the monorepo? Problem When I import prisma from the package in my
web
app, prisma is unable to locate the
schema.prisma
file:
Copy code
error - Error: ENOENT: no such file or directory, open '/Users/xxx/rootDir/apps/web/.next/server/pages/api/trpc/schema.prisma'
This may be related to the following prisma issues: • https://github.com/prisma/prisma/issues/9435#issuecomment-1065879963https://github.com/prisma/prisma/issues/10512 (supposed to be fixed via #12427) Context • I have a monorepo setup with an
apps/web
nextJS app and a separate
packages/database
package with prisma inside. • The database package builds via tsup to
packages/database/dist
.
Copy code
apps/
├─ web/                          # <-- nextJS app (unable to detect schema)
packages/
├─ database/
│  ├─ prisma/                    # prisma setup
│  │  ├─ schema.prisma
│  ├─ src/
│  │  ├─ client.ts               # exports PrismaClient & global.prisma type in prod
│  │  ├─ index.ts                # exports from prisma client
│  │  ├─ seed.ts                 # prisma seeding script for local dev
│  ├─ .env.example               # `DATABASE_URL` env var
│  ├─ tsup.config.js             # builds to /dist folder in this package
h
Did you solve this problem? I have same issue
r
No, not yet! :( I've seen quite a few people having issues with Prisma in a monorepo.
n
Hey Richard 👋 Is this Issue still persisting for you once you upgrade to the latest dev prisma version available as
@prisma/client@dev
Referring to this comment
r
Hi @Nurul, so I spent most of the day today to resolve this and it finally worked. I had updated prisma earlier and the issue was present. I didn’t update it today but was able to resolve the issue. To be honest, I’m not 100% certain what the problem was but mainly played around with package.json’s & turbo.json after I saw in some log that the prisma-client configuration was set up properly.
🙌 1
Thanks for following up though, really appreciate it. 🙏
🙌 1
m
@Richard I am trying to do the same, do you maybe have a sample repo? 😄
r
@manuel I do not unfortunately. But if you have a repo, I can try and take a look. (sorry for the embarrassingly delay in responding)