Code Monkey home page Code Monkey logo

Comments (11)

aryansindhi18 avatar aryansindhi18 commented on May 25, 2024 4

I was facing the same issue, got solved by importing @prisma/client/edge instead of @prisma/client,
thanks @AbrahamX3 !!!

from prisma.

janpio avatar janpio commented on May 25, 2024 1

@iflamed If you are using D1, then you are not using Prisma Accelerate, which this issue is about - you are in the wrong place. Please open a new issue and describe your problem, then we can try to help. Thanks.

from prisma.

AbrahamX3 avatar AbrahamX3 commented on May 25, 2024

Hey, I noticed you're importing the PrismaClient from @prisma/client instead of @prisma/client/edge, you should be using the edge import if you're deploying to Cloudflare Workers. This should make things work!

You can find this in their documentation: https://www.prisma.io/docs/accelerate/getting-started#24-extend-your-prisma-client-instance-with-the-accelerate-extension

from prisma.

janpio avatar janpio commented on May 25, 2024

@codewithharshjha Did you see the response from @AbrahamX3? Did this help?

from prisma.

iflamed avatar iflamed commented on May 25, 2024

I was facing the same issue, got solved by importing @prisma/client/edge instead of @prisma/client, thanks @AbrahamX3 !!!

This not works for me.
Got this error:

"PrismaClientValidationError: Prisma Client was configured to use the `adapter` option but it was imported via its `/edge` endpoint.\nPlease either remove the `/edge` endpoint or remove the `adapter` from the Prisma Client constructor."

from prisma.

AbrahamX3 avatar AbrahamX3 commented on May 25, 2024

Hey @iflamed, looking at the error message, if your Prisma client looks something like this:

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

Then it should look like the following, if you're using edge runtime and Prisma Accelerate (if your database doesn't support an edge runtime), here's how to get started with Prisma Accelerate https://www.prisma.io/docs/accelerate/getting-started

import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const prisma = new PrismaClient().$extends(withAccelerate())

If you're using a specific adapter, you can go to their documentation and see which ones are edge compatible https://www.prisma.io/docs/orm/prisma-client/deployment/edge/overview#which-database-drivers-are-edge-compatible

If you find one of your adapter/database in the list, you can then head over to https://www.prisma.io/docs/orm/overview/databases and pick your database for a more detailed documentation on how to set up your Prisma client.

from prisma.

iflamed avatar iflamed commented on May 25, 2024

Hey @iflamed, looking at the error message, if your Prisma client looks something like this:

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

Then it should look like the following, if you're using edge runtime and Prisma Accelerate (if your database doesn't support an edge runtime), here's how to get started with Prisma Accelerate https://www.prisma.io/docs/accelerate/getting-started

import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const prisma = new PrismaClient().$extends(withAccelerate())

If you're using a specific adapter, you can go to their documentation and see which ones are edge compatible https://www.prisma.io/docs/orm/prisma-client/deployment/edge/overview#which-database-drivers-are-edge-compatible

If you find one of your adapter/database in the list, you can then head over to https://www.prisma.io/docs/orm/overview/databases and pick your database for a more detailed documentation on how to set up your Prisma client.

However, I have another problem, the PrismaClient will result failed to deploy to cloudflare.

const adapter = new PrismaD1(c.env.DB)
prismaCli = new PrismaClient({ adapter })

from prisma.

AbrahamX3 avatar AbrahamX3 commented on May 25, 2024

@iflamed what error does it give you?

Also in your prisma/schema.prisma, do you have the following configuration for generator client?

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

from prisma.

iflamed avatar iflamed commented on May 25, 2024

@iflamed what error does it give you?

Also in your prisma/schema.prisma, do you have the following configuration for generator client?

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

Yes, here is the schema.prisma

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

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

from prisma.

AbrahamX3 avatar AbrahamX3 commented on May 25, 2024

@iflamed Interesting, I have never used D1, so I'm not really sure how to fully deploy it, you can follow their documentation though https://developers.cloudflare.com/d1/tutorials/d1-and-prisma-orm/#what-is-prisma-orm

If you already have, maybe @janpio can further assist you but he's probably gonna need some more context on the error you get when deploying.

from prisma.

iflamed avatar iflamed commented on May 25, 2024

@AbrahamX3 @janpio Will you try this branch https://github.com/iflamed/hono-react-ssr-shadcn-ui/tree/prisma-debug, Follow these command below will deploy success in the cli, but failed on the cloudflare dashboard.

npm run install
npx prisma generate
npm run deploy

from prisma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.