ERROR Nuxt Build Error: [commonjs--resolver] Invalid module ".prisma/client/index-browser"

Hi i'm using Nuxt 4 + Prisma and i'm trying to build it but there's an error on it. Here's th version: "@prisma/client": "^6.14.0", "@prisma/nuxt": "^0.3.0",
5 Replies
Prisma AI Help
Skipping coffee for instant knowledge! Let's brew that AI answer now. This error is a known issue when using Nuxt (including Nuxt 3 and 4) with Prisma, especially with recent versions of both. The error:
Nuxt Build Error: [commonjs--resolver] Invalid module ".prisma/client/index-browser"
Nuxt Build Error: [commonjs--resolver] Invalid module ".prisma/client/index-browser"
occurs because the build process cannot resolve the .prisma/client/index-browser module specifier. This is typically due to how Vite (used by Nuxt) handles module resolution for Prisma's generated client. Solution:
Add a Vite alias in your nuxt.config.ts to explicitly map .prisma/client/index-browser to the correct file:
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
modules: [
'@prisma/nuxt',
],
vite: {
resolve: {
alias: {
'.prisma/client/index-browser': './node_modules/.prisma/client/index-browser.js',
},
},
},
})
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
modules: [
'@prisma/nuxt',
],
vite: {
resolve: {
alias: {
'.prisma/client/index-browser': './node_modules/.prisma/client/index-browser.js',
},
},
},
})
This workaround is recommended in the official Prisma documentation and has been confirmed by multiple users to resolve the build error in both development and production environments. If you are using pnpm and encounter issues, ensure you have a .npmrc file with hoist-pattern[]=*prisma* to hoist dependencies properly. Also, avoid customizing the Prisma Client output directory, as @prisma/nuxt expects the client in its default location within node_modules<sup>Prisma Nuxt Module Troubleshooting</sup>. If you still encounter issues, double-check that you do not have any custom output set in your schema.prisma generator block, and that you have run npx prisma generate after any changes. Let me know if you need more help!
Nurul
Nurul3w ago
Did the bot recommendation help?
Prisma AI Help
✅ Great, thanks for letting us know that this solved your question!
MarquiPaul
MarquiPaulOP3w ago
Yes the build is successful
Nurul
Nurul2w ago
Glad to hear that!

Did you find this page helpful?