P
Prisma5w ago
Paul

Yarn monorepo, vite, tanstack router: ERROR: Could not resolve ".prisma/client/index-browser"

Node.js v22.12.0
✘ [ERROR] Could not resolve ".prisma/client/index-browser"

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

The Yarn Plug'n'Play manifest forbids importing ".prisma" here because it's not listed as a
dependency of this package:

../../../../../../.pnp.cjs:37:31:
37 │ "packageDependencies": [\
╵ ~~

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.

15:44:33 [vite] (client) error while updating dependencies:
Error: Build failed with 1 error:
../../node_modules/@prisma/client/index-browser.js:1:23: ERROR: Could not resolve ".prisma/client/index-browser"
at failureErrorWithLog (/Users/paul/development/src/github/[project]/node_modules/esbuild/lib/main.js:1476:15)
at /Users/paul/development/src/github/[project]/node_modules/esbuild/lib/main.js:945:25
at /Users/paul/development/src/github/[project]/node_modules/esbuild/lib/main.js:1354:9
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Node.js v22.12.0
✘ [ERROR] Could not resolve ".prisma/client/index-browser"

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

The Yarn Plug'n'Play manifest forbids importing ".prisma" here because it's not listed as a
dependency of this package:

../../../../../../.pnp.cjs:37:31:
37 │ "packageDependencies": [\
╵ ~~

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.

15:44:33 [vite] (client) error while updating dependencies:
Error: Build failed with 1 error:
../../node_modules/@prisma/client/index-browser.js:1:23: ERROR: Could not resolve ".prisma/client/index-browser"
at failureErrorWithLog (/Users/paul/development/src/github/[project]/node_modules/esbuild/lib/main.js:1476:15)
at /Users/paul/development/src/github/[project]/node_modules/esbuild/lib/main.js:945:25
at /Users/paul/development/src/github/[project]/node_modules/esbuild/lib/main.js:1354:9
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Tried various things, can't get past this.
Solution:
I tried this: https://github.com/prisma/prisma/discussions/20200 and adding to vite config: ``` alias: {...
Jump to solution
2 Replies
Solution
Paul
Paul5w ago
I tried this: https://github.com/prisma/prisma/discussions/20200 and adding to vite config:
alias: {
'.prisma/client/index-browser': '../../node_modules/@prisma-app/client/index-browser.js',
},
alias: {
'.prisma/client/index-browser': '../../node_modules/@prisma-app/client/index-browser.js',
},
and then exporting from the db package
import { PrismaClient } from '@prisma-app/client';

export const prisma = new PrismaClient();
import { PrismaClient } from '@prisma-app/client';

export const prisma = new PrismaClient();
resolved it. 😅
RaphaelEtim
RaphaelEtim5w ago
Thanks for sharing the solution that worked for you.

Did you find this page helpful?