Skip to content

Importing enum in browsers results in `Error resolving module specifier “.prisma/client/index-browser”.  #12504

@wvhulle

Description

@wvhulle

Bug description

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 ...

How to reproduce

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.

Expected behavior

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.

Prisma information

I cannot share the schema, but this is the query that happens on the page where the error happens.

import prisma from '$lib/db';

export async function get() {
    const projects = await prisma.project.findMany({})
    return { body: projects }
}

And i am using this solution for the production build of Sveltekit:

import pkg, { PrismaClient } from '@prisma/client';
import { dev } from '$app/env';

declare global {
    var _prisma: PrismaClient; // eslint-disable-line
}

let prisma;
if (dev) {
    if (!global._prisma) {
        global._prisma = new PrismaClient();
    }
    prisma = global._prisma;
} else {
    const { PrismaClient: PrismaClientProd } = pkg;
    prisma = new PrismaClientProd();
}

export default prisma as PrismaClient; // type assertion for shim

Environment & setup

  • OS: Linux Mint 20.3
  • Database: PostgreSQL
  • Node.js version: v17.8.0

Prisma Version

prisma                  : 3.11.0
@prisma/client          : 3.11.0
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine b371888aaf8f51357c7457d836b86d12da91658b (at ../../../../.pnpm-store/v3/tmp/_npx/69216/5/node_modules/.pnpm/@prisma+engines@3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli b371888aaf8f51357c7457d836b86d12da91658b (at ../../../../.pnpm-store/v3/tmp/_npx/69216/5/node_modules/.pnpm/@prisma+engines@3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b/node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core b371888aaf8f51357c7457d836b86d12da91658b (at ../../../../.pnpm-store/v3/tmp/_npx/69216/5/node_modules/.pnpm/@prisma+engines@3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b/node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt b371888aaf8f51357c7457d836b86d12da91658b (at ../../../../.pnpm-store/v3/tmp/_npx/69216/5/node_modules/.pnpm/@prisma+engines@3.11.0-48.b371888aaf8f51357c7457d836b86d12da91658b/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : b371888aaf8f51357c7457d836b86d12da91658b
Studio                  : 0.458.0
Preview Features        : fullTextSearch

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions