P
Prisma3w ago
Abakir

I keep getting this error `Object literal may only specify known properties, and 'adapter' CF D1

I am using Cloudflare D1 and I keep getting this error Object literal may only specify known properties, and 'adapter' does not exist in type 'Subset<PrismaClientOptions, PrismaClientOptions>'.ts(2353) Using this code:
const adapter = new PrismaD1(env.database);
const prisma = new PrismaClient({ adapter });
const adapter = new PrismaD1(env.database);
const prisma = new PrismaClient({ adapter });
My Prisma file looks like this:
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
output = "../prisma-client"
}

datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
output = "../prisma-client"
}

datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
7 Replies
Prisma AI Help
You're in no rush, so we'll let a dev step in. Enjoy your coffee, or drop into #ask-ai if you get antsy for a second opinion!
Abakir
AbakirOP3w ago
Am I doing something wrong where I get this error with passing adapter in const prisma = new PrismaClient({ adapter });
"devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.5.2",
"@cloudflare/workers-types": "^4.20241022.0",
"@types/node": "^22.10.2",
"prisma": "^6.7.0",
"typescript": "^5.5.2",
"vitest": "2.0.5",
"wrangler": "^3.84.1"
},
"dependencies": {
"@prisma/adapter-d1": "^6.7.0",
"@prisma/client": "^6.7.0",
"@prisma/extension-accelerate": "^1.3.0",
"dotenv": "^16.5.0",
"hono": "^4.7.2",
"langchain": "^0.3.7"
}
"devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.5.2",
"@cloudflare/workers-types": "^4.20241022.0",
"@types/node": "^22.10.2",
"prisma": "^6.7.0",
"typescript": "^5.5.2",
"vitest": "2.0.5",
"wrangler": "^3.84.1"
},
"dependencies": {
"@prisma/adapter-d1": "^6.7.0",
"@prisma/client": "^6.7.0",
"@prisma/extension-accelerate": "^1.3.0",
"dotenv": "^16.5.0",
"hono": "^4.7.2",
"langchain": "^0.3.7"
}
Nurul
Nurul3w ago
Hey! Did you try following this guide? https://www.prisma.io/docs/guides/cloudflare-d1
How to use Prisma ORM with Cloudflare D1 | Prisma Documentation
Learn how to use Prisma ORM with Cloudflare D1
Nurul
Nurul3w ago
Do you get the same error if you follow the steps mentioned in the guide?
Nurul
Nurul3w ago
GitHub
prisma-examples/deployment-platforms/edge/cloudflare-workers/with-d...
🚀 Ready-to-run Prisma example projects. Contribute to prisma/prisma-examples development by creating an account on GitHub.
Abakir
AbakirOP3w ago
I did and I get the same issue I am using hono for api endpoints
// index.ts - Main entry point for the Cloudflare Worker
import { Hono } from 'hono'


import { PrismaClient } from '@prisma/client'
import { PrismaD1 } from '@prisma/adapter-d1'

export interface Env {
Bindings: {
database: D1Database;
OPENAI_API_KEY: string;
}
}
export const CACHE_CONTROL_24H = () => 86400;


const app = new Hono<{ Bindings: Env }>();

app.get('/', (c) => {
console.log('Hello World');
console.log(c.env);
const adapter = new PrismaD1(c.env.Bindings.database);
const prisma = new PrismaClient({ adapter });
return c.json({ message: 'Hello World' }, 200);
});



export default app
// index.ts - Main entry point for the Cloudflare Worker
import { Hono } from 'hono'


import { PrismaClient } from '@prisma/client'
import { PrismaD1 } from '@prisma/adapter-d1'

export interface Env {
Bindings: {
database: D1Database;
OPENAI_API_KEY: string;
}
}
export const CACHE_CONTROL_24H = () => 86400;


const app = new Hono<{ Bindings: Env }>();

app.get('/', (c) => {
console.log('Hello World');
console.log(c.env);
const adapter = new PrismaD1(c.env.Bindings.database);
const prisma = new PrismaClient({ adapter });
return c.json({ message: 'Hello World' }, 200);
});



export default app
Here is my index file But I still get the error Object literal may only specify known properties, and 'adapter' does not exist in type 'Subset<PrismaClientOptions, PrismaClientOptions>'.ts( @Nurul (Prisma) I am trying to push to cloudlfare workers The error in the cloudflare log is
Error: PrismaClient is not configured to run in Cloudflare Workers. In order to run Prisma Client on edge runtime, either:

- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report
at Object.get
Error: PrismaClient is not configured to run in Cloudflare Workers. In order to run Prisma Client on edge runtime, either:

- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report
at Object.get
But I am using the latest prisma version The issue was when adding
output = "../prisma-client"
output = "../prisma-client"
to the prisma schema npx prisma generate would update the types outside node_modules so when importing the function, PrismaClient with the adaptar it did not have the correct types
Nurul
Nurul2w ago
Hey! If I understand correctly, the issue got resolved after you removed output?

Did you find this page helpful?