P
Prisma2mo ago
cgm

Issue deploying on Cloudflare Workers with Prisma Accelerate + Prisma Postgres

Hi, when I am trying to deploy on Clouldflare Workers with Prisma Accelerate and Prisma Postgres. I am getting the following issues in the build and then when navigating to the page: In the build:
...
10:14:06.784 ✓ built in 4.13s
10:14:06.784 vite v7.1.9 building SSR bundle for production...
10:14:06.787 transforming...
10:14:09.949 ".prisma/client/default" is imported by ".prisma/client/default?commonjs-external", but could not be resolved – treating it as an external dependency.
10:14:16.606 ✓ 3819 modules transformed.
10:14:17.314 rendering chunks...
...
...
10:14:06.784 ✓ built in 4.13s
10:14:06.784 vite v7.1.9 building SSR bundle for production...
10:14:06.787 transforming...
10:14:09.949 ".prisma/client/default" is imported by ".prisma/client/default?commonjs-external", but could not be resolved – treating it as an external dependency.
10:14:16.606 ✓ 3819 modules transformed.
10:14:17.314 rendering chunks...
...
Error when viewing deployed:
{"status":500,"unhandled":true,"message":"HTTPError"}
{"status":500,"unhandled":true,"message":"HTTPError"}
and testing the Worker Clouldflare side:
assets/worker-entry-0E0HEGVa.js:19481 HTTPError: No such module "assets/.prisma/client/default".
imported from "assets/db-SP2WOBxu.js"
Caused by: Error: No such module "assets/.prisma/client/default".
imported from "assets/db-SP2WOBxu.js"
assets/worker-entry-0E0HEGVa.js:19481 HTTPError: No such module "assets/.prisma/client/default".
imported from "assets/db-SP2WOBxu.js"
Caused by: Error: No such module "assets/.prisma/client/default".
imported from "assets/db-SP2WOBxu.js"
10 Replies
Prisma AI Help
Prisma AI Help2mo ago
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the #ask-ai channel awaits if you're curious!
Aman
Aman2mo ago
Can you show me your schema.prisma file?
cgm
cgmOP2mo ago
yep!
generator client {
provider = "prisma-client-js"
engineType = "client"
}

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

model User {
id String @id @default(cuid())
phone String @unique
name String?
username String? @unique
posts Post[]
categories Category[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

@@map("users")
}

model Post {
id String @id @default(cuid())
userId String @map("user_id")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
url String
title String?
description String?
isPrivate Boolean @default(false) @map("is_private")
previewTitle String? @map("preview_title")
previewDescription String? @map("preview_description")
previewImage String? @map("preview_image")
previewFavicon String? @map("preview_favicon")
categories Category[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

@@index([userId, createdAt])
@@map("posts")
}

model Category {
id String @id @default(cuid())
name String
userId String @map("user_id")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
posts Post[]
createdAt DateTime @default(now()) @map("created_at")

@@unique([userId, name])
@@map("categories")
}
generator client {
provider = "prisma-client-js"
engineType = "client"
}

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

model User {
id String @id @default(cuid())
phone String @unique
name String?
username String? @unique
posts Post[]
categories Category[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

@@map("users")
}

model Post {
id String @id @default(cuid())
userId String @map("user_id")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
url String
title String?
description String?
isPrivate Boolean @default(false) @map("is_private")
previewTitle String? @map("preview_title")
previewDescription String? @map("preview_description")
previewImage String? @map("preview_image")
previewFavicon String? @map("preview_favicon")
categories Category[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

@@index([userId, createdAt])
@@map("posts")
}

model Category {
id String @id @default(cuid())
name String
userId String @map("user_id")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
posts Post[]
createdAt DateTime @default(now()) @map("created_at")

@@unique([userId, name])
@@map("categories")
}
Aman
Aman2mo ago
Try the rust free version of Prisma ORM
cgm
cgmOP2mo ago
I assume this section specifically for me right?
Aman
Aman2mo ago
with prisma-client generator
Aman
Aman2mo ago
generator client {
provider = "prisma-client"
output = "./generated"
engineType = "client"
runtime = "workerd"
}
generator client {
provider = "prisma-client"
output = "./generated"
engineType = "client"
runtime = "workerd"
}
Try this config, you will have to update all the imports of prisma client to ../prisma/generated/client also generate the client again npx prisma generate
cgm
cgmOP2mo ago
okay now the build is failing:
...
✓ 3817 modules transformed.
10:44:42.320 ✗ Build failed in 6.88s
10:44:42.321 error during build:
10:44:42.321 src/db.ts (2:9): "PrismaClient" is not exported by "src/generated/prisma/client.js", imported by "src/db.ts".
10:44:42.321 file: /opt/buildhome/repo/src/db.ts:2:9
10:44:42.322
10:44:42.322 1: import { withAccelerate } from "@prisma/extension-accelerate";
10:44:42.322 2: import { PrismaClient } from "@/generated/prisma/client";
10:44:42.322 ^
10:44:42.322 3:
10:44:42.322 4: //test
...
...
✓ 3817 modules transformed.
10:44:42.320 ✗ Build failed in 6.88s
10:44:42.321 error during build:
10:44:42.321 src/db.ts (2:9): "PrismaClient" is not exported by "src/generated/prisma/client.js", imported by "src/db.ts".
10:44:42.321 file: /opt/buildhome/repo/src/db.ts:2:9
10:44:42.322
10:44:42.322 1: import { withAccelerate } from "@prisma/extension-accelerate";
10:44:42.322 2: import { PrismaClient } from "@/generated/prisma/client";
10:44:42.322 ^
10:44:42.322 3:
10:44:42.322 4: //test
...
schema:
generator client {
provider = "prisma-client-js"
output = "../src/generated/prisma"
engineType = "client"
runtime = "workerd"
}
generator client {
provider = "prisma-client-js"
output = "../src/generated/prisma"
engineType = "client"
runtime = "workerd"
}
db.ts:
import { withAccelerate } from "@prisma/extension-accelerate";
import { PrismaClient } from "@/generated/prisma/client"; // I updated it here, and everwhere else in the app

const prisma = new PrismaClient().$extends(withAccelerate());
export { prisma };
import { withAccelerate } from "@prisma/extension-accelerate";
import { PrismaClient } from "@/generated/prisma/client"; // I updated it here, and everwhere else in the app

const prisma = new PrismaClient().$extends(withAccelerate());
export { prisma };
and this is beng ran before it:
10:44:28.310 Loaded Prisma config from prisma.config.ts.
10:44:28.310
10:44:28.353 Prisma config detected, skipping environment variable loading.
10:44:28.355 Prisma schema loaded from prisma/schema.prisma
10:44:28.507
10:44:28.507 ✔ Generated Prisma Client (v6.17.1, engine=none) to ./src/generated/prisma in 78ms
10:44:28.507
10:44:28.507 Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)
10:44:28.507
10:44:28.508 Tip: Want to turn off tips and other hints? https://pris.ly/tip-4-nohints
10:44:28.508
10:44:28.571 Done in 25.1s
10:44:28.653 Executing user build command: pnpm run build
10:44:28.997
10:44:28.998 > hyperlink-social@ build /opt/buildhome/repo
10:44:28.998 > vite build
10:44:28.998
10:44:31.055 vite v7.1.9 building for production...
10:44:28.310 Loaded Prisma config from prisma.config.ts.
10:44:28.310
10:44:28.353 Prisma config detected, skipping environment variable loading.
10:44:28.355 Prisma schema loaded from prisma/schema.prisma
10:44:28.507
10:44:28.507 ✔ Generated Prisma Client (v6.17.1, engine=none) to ./src/generated/prisma in 78ms
10:44:28.507
10:44:28.507 Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)
10:44:28.507
10:44:28.508 Tip: Want to turn off tips and other hints? https://pris.ly/tip-4-nohints
10:44:28.508
10:44:28.571 Done in 25.1s
10:44:28.653 Executing user build command: pnpm run build
10:44:28.997
10:44:28.998 > hyperlink-social@ build /opt/buildhome/repo
10:44:28.998 > vite build
10:44:28.998
10:44:31.055 vite v7.1.9 building for production...

Did you find this page helpful?