pnpm workspace/monorepo using nuxt: ✘ [ERROR] Could not resolve ".prisma/client/index-browser"

I think this is related (maybe) to this known issue: https://www.prisma.io/docs/orm/more/help-and-troubleshooting/prisma-nuxt-module#resolving-typeerror-failed-to-resolve-module-specifier-prismaclientindex-browser here's my error:
✘ [ERROR] Could not resolve ".prisma/client/index-browser"

../../node_modules/.pnpm/@prisma+client@6.14.0_typescript@5.9.2/node_modules/@prisma/client/index-browser.js:1:23:
1 │ const prisma = require('.prisma/client/index-browser')
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can mark the path ".prisma/client/index-browser" as external to exclude it from the bundle,
which will remove this error and leave the unresolved path in the bundle. You can also surround
this "require" call with a try/catch block to handle this failure at run-time instead of
bundle-time.
✘ [ERROR] Could not resolve ".prisma/client/index-browser"

../../node_modules/.pnpm/@prisma+client@6.14.0_typescript@5.9.2/node_modules/@prisma/client/index-browser.js:1:23:
1 │ const prisma = require('.prisma/client/index-browser')
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can mark the path ".prisma/client/index-browser" as external to exclude it from the bundle,
which will remove this error and leave the unresolved path in the bundle. You can also surround
this "require" call with a try/catch block to handle this failure at run-time instead of
bundle-time.
but when i add the fix, i still get the same error i am using the nuxt module, and the prisma stuff is in a separate nuxt layer. so i assume there are quite a few points of failure, but maybe somebody has experienced this already? perhaps i just need to put a different path in the vite alias cuz of the pnpm workspace does funky things, or hoisting something specific (i don't understand hoisting tbh)
Add Prisma ORM Easily to Your Nuxt Apps | Prisma Documentation
Learn how to easily add Prisma ORM to your Nuxt apps, use its features, and understand its limitations.
3 Replies
Prisma AI Help
Well met, adventurer! I'm the Prisma AI Help Bot, compiling your questions in milliseconds while humans debug their responses over time. Who’s on your team?
Nurul
Nurul3w ago
The workaround mentioned usually fixes the issue. Are you using the latest prisma version - 6.14.0?
thejacer87
thejacer87OP2w ago
as far as i am aware, yes, i am using 6.14.0 .pnpm/@prisma+client@6.14.0_typescript@5.9.2 in the error should confirm that, correct? to follow up, probably unhelpfully... but without adding the fix from the docs, or doing any other intentional fixes i can now load up the site and develop. i use the prisma module in a separate layer from the main web app (using pnpm workspace - monorepo) problem now is, when i try to build the nuxt app, the error shows up again
[10:11:36 a.m.] ERROR ✗ Build failed in 1.40s

[nuxi 10:11:36 a.m.] ERROR Nuxt Build Error: [commonjs--resolver] Invalid module ".prisma/client/index-browser" is not a valid package name
[10:11:36 a.m.] ERROR ✗ Build failed in 1.40s

[nuxi 10:11:36 a.m.] ERROR Nuxt Build Error: [commonjs--resolver] Invalid module ".prisma/client/index-browser" is not a valid package name
so that's no fun if i add the fix from the docs, it still doesnt build BUT, if i add this fix from claude:
vite: {
optimizeDeps: {
include: ['@prisma/client'],
},
build: {
rollupOptions: {
external: ['.prisma/client/index-browser'],
},
},
},
vite: {
optimizeDeps: {
include: ['@prisma/client'],
},
build: {
rollupOptions: {
external: ['.prisma/client/index-browser'],
},
},
},
the site does build 🎉 , unfortunately 🫠 when i run the site with node .output/server/index.mjs while the site does load, i get this error in the browser console:
Uncaught TypeError: Failed to resolve module specifier ".prisma/client/index-browser". Relative references must start with either "/", "./", or "../".
Uncaught TypeError: Failed to resolve module specifier ".prisma/client/index-browser". Relative references must start with either "/", "./", or "../".
and the site doesnt function properly, likely due to js not working properly not sure if the rollup "fix" that claude suggested is indicative of anything, but ya, could use some help 🙏

Did you find this page helpful?