prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
39.11k stars 1.53k forks source link

@prisma/extension-pulse is not exported from package #24130

Open jeffreybos opened 4 months ago

jeffreybos commented 4 months ago

Bug description

I want to use Prisma Pulse, but when i import (and ofcourse i installed the package with NPM) the package. I get the following error.

./lib/db.ts:2:0 Module not found: Package path . is not exported from package /node_modules/@prisma/extension-pulse (see exports field in /node_modules/@prisma/extension-pulse/package.json)

I've checked the node_modules and @prisma/extension-pulse is in there

image

I'm. using NextJS 14.1.4 and Prisma 5.13.0 and @prisma/extension-pulse 1.0.2

How to reproduce

Expected behavior

No response

Prisma information

// prisma/schema.prisma
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

enum UserRole {
  ADMIN
  USER
}

model User {
  id                    String                 @id @default(cuid())
  name                  String?
  email                 String?                @unique
  emailVerified         DateTime?
  image                 String?
  password              String?
  role                  UserRole               @default(USER)
  accounts              Account[]
  isTwoFactorEnabled    Boolean                @default(false)
  twoFactorConfirmation TwoFactorConfirmation?
  Team                  Team[]
}

model Account {
  id                String  @id @default(cuid())
  userId            String
  type              String
  provider          String
  providerAccountId String
  refresh_token     String? @db.Text()
  access_token      String? @db.Text()
  expires_at        Int?
  token_type        String?
  scope             String?
  id_token          String? @db.Text()
  session_state     String?

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model VerificationToken {
  id      String   @id @default(cuid())
  email   String
  token   String   @unique
  expires DateTime

  @@unique([email, token])
}

model PasswordResetToken {
  id      String   @id @default(cuid())
  email   String
  token   String   @unique
  expires DateTime

  @@unique([email, token])
}

model TwoFactorToken {
  id      String   @id @default(cuid())
  email   String
  token   String   @unique
  expires DateTime

  @@unique([email, token])
}

model TwoFactorConfirmation {
  id String @id @default(cuid())

  userId String
  user   User   @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([userId])
}

model Team {
  id     String @id @default(cuid())
  name   String
  userId String
  user   User   @relation(fields: [userId], references: [id], onDelete: Cascade)
}

Environment & setup

NextJS 14.1.4

Prisma Version

Prisma 5.13.0 Pulse 1.0.2

rtbenfield commented 4 months ago

Hi @jeffreybos 👋🏻 Thanks for raising this. With your NextJS app, are you attempting to use Prisma Pulse in an edge function or serverless function?

jeffreybos commented 4 months ago

I'm using it with supabase. I followed the prisms pulse guide for setting up my project.

But the issue right now is that the installed pulse npm package is not recognized as a module

katungi commented 4 months ago

I have just encountered the same issue currently. I am also using supabase.

rwenzlofsky commented 4 months ago

I have the same issue

raamponsah commented 4 months ago

I am using postgresql on railway

nurul3101 commented 4 months ago

Hey folks!

Can you please confirm that you have set customConditions in your "tsconfig.json" file as specified here?

Screenshot 2024-05-13 at 5 32 23 PM
ThomasBnf commented 4 months ago

Hi, i have the same issue, @jeffreybos did you find a solution ? I using Supabase aswell

nurul3101 commented 4 months ago

@ThomasBnf To confirm, you have set customConditions in your "tsconfig.json" file as mentioned here and are still getting the issue, right?

ThomasBnf commented 4 months ago

yes, exactly, i tried with "customConditions":["workerd"] or ["node"]

nurul3101 commented 4 months ago

Thanks for confirming. Our team has take a note of this and will get back with further updates.

mehran9 commented 3 months ago

I have the exact same issue.

jkumara commented 3 months ago

I also encountered this. NextJS app with Postgresql.

jkumara commented 3 months ago

@nurul3101 Are there any updates for a fix to this?

jkumara commented 3 months ago

Actually, I was able to figure what was going wrong in my case. The file that was importing the Pulse-extension was being included in some client-side code. Since the package's exports specify "node" and "workerd" environments, nothing was obviously being exported for the browser. I'll fix it in my repo.

Thanks anyway.

ankur-arch commented 3 months ago

@ThomasBnf is your case by any chance similar to @jkumara, where the exports are not working for the browser?

nurul3101 commented 2 months ago

We released a new Prisma Pulse extension version 1.2.0: https://www.npmjs.com/package/@prisma/extension-pulse

It's now possible to import from @prisma/extension-pulse/node or @prisma/extension-pulse/workerd as an alternative to using the customConditions setting in tsconfig.

If you are running into this issue, please try importing either from @prisma/extension-pulse/node or @prisma/extension-pulse/workerd depending on your runtime.