Skip to content

Unable to interop export * from "@prisma/client" in /home/[user]/Documents/[project]/packages/db/index.ts, this may lose module exports. Please export "@prisma/client" as ESM or use named exports instead, e.g. export { A, B } from "@prisma/client" #21474

@kyle-belle

Description

@kyle-belle

Bug description

I am working in a monorepo with a VITE frontend and Express/trpc api which uses Prisma for the db

When trying to run the frontend i get the error:

Unable to interop `export * from "@prisma/client"` in /home/[user]/Documents/[project]/packages/db/index.ts, this may lose module exports. Please export "@prisma/client" as ESM or use named exports instead, e.g. `export { A, B } from "@prisma/client"`

packages/db/index.ts

import "./config";
import { __PRODUCTION__ } from "@ai-schedule/values";
import { PrismaClient as BasePrismaClient, Prisma } from '@prisma/client';

const ProxyPrisma = new Proxy(BasePrismaClient, {
  construct(_PrismaClient, args) {
    if (typeof window !== "undefined") return {}
    
    // @ts-ignore
    globalThis.prisma = globalThis.prisma || new _PrismaClient(...args);
    
    // @ts-ignore
    return globalThis.prisma;
  },
});

const getPrismaClient = () => {
  return new ProxyPrisma()
};

export type PrismaClient = ReturnType<typeof getPrismaClient>

export const prisma = getPrismaClient();

export * from "@prisma/client"
export { BasePrismaClient, Prisma };

This is the Browser console error: Uncaught SyntaxError: ambiguous indirect export: UserType

This is the line when i view the transpiled source the browser is trying to run import { UserType } from "/@fs/home/[user]/Documents/[project]/packages/db/index.ts";

How to reproduce

Run the project using yarn dev

Expected behavior

Expected project to run normally

Prisma information

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["fullTextIndex", "fullTextSearch"]
}

generator zod {
  provider                         = "zod-prisma-types"
  output                           = "./generated/zod" // default is ./generated/zod
  useMultipleFiles                 = true // default is false
  writeBarrelFiles                 = true // default is true
  createInputTypes                 = true // default is true
  createModelTypes                 = true // default is true
  addInputTypeValidation           = true // default is true
  addIncludeType                   = true // default is true
  addSelectType                    = true // default is true
  validateWhereUniqueInput         = false // default is false
  createOptionalDefaultValuesTypes = true // default is false
  createRelationValuesTypes        = true // default is false
  createPartialTypes               = true // default is false
  useDefaultValidators             = true // default is true
  coerceDate                       = false // default is true
  writeNullishInModelTypes         = false // default is false
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

enum UserType {
  ADMIN
  STUDENT
}

/// There is no problem with the models as it runs on the backend and queries work.
/// Models
/// ... 

Environment & setup

  • OS: Linux
  • Database: MySQL
  • Node.js version: v18.17.1

Prisma Version

prisma                  : 5.4.1
@prisma/client          : 5.4.1
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 2f302df92bd8945e20ad4595a73def5b96afa54f (at ../../node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Schema Engine           : schema-engine-cli 2f302df92bd8945e20ad4595a73def5b96afa54f (at ../../node_modules/@prisma/engines/schema-engine-debian-openssl-1.1.x)
Schema Wasm             : @prisma/prisma-schema-wasm 5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59
Default Engines Hash    : 2f302df92bd8945e20ad4595a73def5b96afa54f
Studio                  : 0.494.0
Preview Features        : fullTextIndex, fullTextSearch
Done in 1.08s.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.tech/typescriptIssue for tech TypeScript.topic: esm

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions