This is a repository to reproduce the error introduced by prisma@5.9.0 in combination with Next.js middleware.
Follow these steps to reproduce the issue:
- Clone this repo
- Run
npm install
to install dependencies - Run
npx prisma generate
to generate prisma client - Run
npm run dev
to start Next.js dev server - Visit http://localhost:3000/ in your browser to trigger middleware (middleware.ts)
- Observe error in terminal and error overlay
⨯ middleware.ts (4:23) @ ModelName ⨯ Cannot read properties of undefined (reading 'ModelName') 2 | 3 | export default function() { > 4 | console.log(Prisma.ModelName.User) | ^ 5 | }
- Based on default Next.js template
reproduction-template
- Installed prisma according to https://www.prisma.io/docs/getting-started/quickstart
- Added a Next.js middleware