Module not found after v6.5.0 upgrade

After upgrading to v6.5.0 these errors occur.
✔ Generated Prisma Client (v6.5.0) to ./node_modules/.pnpm/@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2/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/@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2/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/@auth+prisma-adapter@2.8.0_@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2_/node_modules/@auth/prisma-adapter/index.js
./lib/auth.ts
./app/api/v1/auth/[...nextauth]/route.ts

./node_modules/.pnpm/@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2/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/@auth+prisma-adapter@2.8.0_@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2_/node_modules/@auth/prisma-adapter/index.js
./lib/auth.ts
./app/api/v1/auth/[...nextauth]/route.ts
✔ Generated Prisma Client (v6.5.0) to ./node_modules/.pnpm/@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2/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/@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2/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/@auth+prisma-adapter@2.8.0_@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2_/node_modules/@auth/prisma-adapter/index.js
./lib/auth.ts
./app/api/v1/auth/[...nextauth]/route.ts

./node_modules/.pnpm/@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2/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/@auth+prisma-adapter@2.8.0_@prisma+client@6.5.0_prisma@6.5.0_typescript@5.8.2__typescript@5.8.2_/node_modules/@auth/prisma-adapter/index.js
./lib/auth.ts
./app/api/v1/auth/[...nextauth]/route.ts
3 Replies
Prisma AI Help
You selected the bot's instantaneous insights. Let me compile your answer right away! 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'
}
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
}
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 andles Node.js built-in modules in environments that don't support them. Similar issues have been reported in various GitHub issues when using Prisma in edge environments. For Next.js 15 specifically, there are ongoing discussions about compatibility with Prisma in edge functions, as mentioned in this GitHub issue. I hope one of these solutions helps resolve your issue! 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Inverse
InverseOP2w ago
I did not have this problem on v6.4.0
Nurul
Nurul7d ago
Hey 👋 Can you please provide a minimal reproduction so that I can test?

Did you find this page helpful?