Example of workaround for using prisma across packages in a monorepo, with multiple schemas and next.js client app
This example npm workspaces - requires npm v7+. But should be repurposable for other package managers.
Workspace folders:
/modules/
/services/
Prisma schemas managed within modules/database/
Example Next.js web app within services/web/
Example unit tests with Jest (not Next.JS specific) within services/web/__tests__/test.ts
- clone repo
npm i
- will install dependencies and trigger
prisma generate
viapostinstall
npm run-script configured inmodules/database/package.json
and called via root/package.json
.
- will install dependencies and trigger
npm run test
to demonstrate Prisma clients work via code elsewhere in monoreponpm run dev
to start Next.js server- open http://localhost:3000 to demonstrate Prisma clients work via Next.js project elsewhere in monorepo