#Module not found after v6.5.0 upgrade

6 messages · Page 1 of 1 (latest)

teal berry
#

After upgrading to v6.5.0 these errors occur.

✔ Generated Prisma Client (v6.5.0) to ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@prisma/client in 63ms

Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)

Tip: Interested in query caching in just a few lines of code? Try Accelerate today! https://pris.ly/tip-3-accelerate

   ▲ Next.js 15.2.4
   - Environments: .env

   Creating an optimized production build ...
Failed to compile.

./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@prisma/client/runtime/library.js:1:2932
Module not found: Can't resolve 'os'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/@auth/prisma-adapter/index.js
./lib/auth.ts
./app/api/v1/auth/[...nextauth]/route.ts

./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@prisma/client/runtime/library.js:1:10153
Module not found: Can't resolve 'crypto'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/@auth/prisma-adapter/index.js
./lib/auth.ts
./app/api/v1/auth/[...nextauth]/route.ts

swift flareBOT
#

You selected the bot's instantaneous insights. Let me compile your answer right away!

swift flareBOT
# swift flare You selected the bot's instantaneous insights. Let me compile your answer right ...

The error you're encountering is related to using Prisma in a Next.js environment, specifically in an Edge Runtime context. The errors indicate that your application is trying to use Node.js built-in modules (os and crypto) which aren't available in the Edge Runtime.

Why this happens

This is a common issue when using Prisma in serverless or edge environments. The error occurs because:

  1. Prisma Client is trying to use Node.js built-in modules (os and crypto)
  2. Next.js Edge Runtime doesn't support these Node.js modules
  3. This is particularly problematic when using Prisma with auth adapters in edge functions

Solutions

There are a few approaches to solve this issue:

1. Move authentication logic to Node.js runtime

The simplest solution is to ensure your auth routes are not using the Edge Runtime. In Next.js, you can do this by:

  • Making sure your auth API routes don't use the export const runtime = 'edge' directive
  • Moving your auth logic to regular Node.js API routes instead of Edge functions

2. Use experimental-serverless-trace target (for older Next.js versions)

For older Next.js versions, adding this to your next.config.js might help:

module.exports = {
  target: 'experimental-serverless-trace'
}

This solution was reported to work in this GitHub issue.

3. Use a custom output path for Prisma Client

If you're using pnpm (as indicated by your error paths), you might need to specify a custom output path for your Prisma Client. In your schema.prisma:

generator client {
  provider = "prisma-client-js"
  output   = "./prisma-client"  // Custom path outside node_modules
}

Then import from this custom path instead of @prisma/client.

4. Downgrade Prisma

As a temporary workaround, you could downgrade to a previous version that worked for you until a fix is available.

Additional context

This issue appears to be related to how Prisma Client h

swift flareBOT
swift flareBOT
teal berry
#

I did not have this problem on v6.4.0