sryscad
sryscad

Reputation: 353

`Uncaught TypeError: Error resolving module specifier “.prisma/client/index-browser”

I have the following error message in my browser upon using sveltekit and the command "npm run preview":

Uncaught TypeError: Error resolving module specifier “.prisma/client/index-browser”. Relative module specifiers must start with “./”, “../” or “/”.

It references a piece of code that was compiled with "npm run build" in localhost:3000/_app/start-b07b1607.js:

...s-d1fb5791.js";import".prisma/client/index-browser";let Be="",et="";function ...

I have tried reproducing this error with using older versions of Prisma, the adaptor and Svelte, switching from pnpm to npm, but nothing helps. I have a MWE repository that comes close to reproducing the error but doesn't actually reproduce it at https://github.com/wvhulle/prisma-sveltekit-bug-report.

How come the Svelte compiler emits “.prisma/client/index-browser” as a module specifier? Is this an error in Prisma, Vite or something else? The dev mode works without problem.

The question seems to be related, but is about Vue, not about Svelte.

Thanks!

Upvotes: 3

Views: 2857

Answers (2)

Jasim Khan
Jasim Khan

Reputation: 1

You need to copy prisma generated files as follows (package.json):

{
  "prisma:inline": "cp ./node_modules/.prisma/client/*.js ./node_modules/@prisma/client",
  "prisma:generate": "prisma generate && npm run prisma:inline"
}

Upvotes: 0

sryscad
sryscad

Reputation: 353

Removing the import of a Prisma enum type fixed the issue.

Somewhere in my code I had import an enum type. This seems to be apparently a Prisma problem.

So, remove any import { Enum } from '@prisma/client'; from your code.

See https://github.com/prisma/prisma/issues/12504

Upvotes: 3

Related Questions