Prisma in deno

I've been having a weird problem with Prisma, when running 100% on deno. Prisma mostly assumes you have a package.json in your project and the biggest problem is that deno just doesn't use it. When I try to run something like prisma generate, it shows the Warning: [Prisma auto-install on generate] Prisma could not find a package.json file in the inferred project root Coding\JS\norslo. During the next step, when an auto-install of Prisma package(s) will be attempted, it will then be created by your package manager on the appropriate level if necessary., then just hangs forever (yes, I've waited for a while for it). Is there any fixes for that integration or is it just not supported now?
16 Replies
Sun「無用」
Sun「無用」OP4w ago
Anyone have ever had that problem?
toni
toni3w ago
I've created simple GitHub repository to run Deno 2 with Prisma https://github.com/tonidy/prisma-deno-example, currently Prisma is lack off ESM, need a workaround to use CJS in deno
GitHub
GitHub - tonidy/prisma-deno-example
Contribute to tonidy/prisma-deno-example development by creating an account on GitHub.
Sun「無用」
Sun「無用」OP3d ago
I kinda forgot to reply here, but the problem persists even with that --unstable-detect-cjs flag I didn't send any messages bc I kinda gave up on prisma with deno, it just doesn't work properly
Inbestigator
Inbestigator3d ago
Works when you add
{
"nodeModulesDir": "auto",
}
{
"nodeModulesDir": "auto",
}
You'll now have a node_modules, but it prevents Prisma from yelling at you and in schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["deno"]
output = "../generated/client"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["deno"]
output = "../generated/client"
}
Sun「無用」
Sun「無用」OP3d ago
that's kinda a lot of stuff, how do you know those? I haven't seen any info on that
Inbestigator
Inbestigator3d ago
bc I had to get Prisma working on a project
Sun「無用」
Sun「無用」OP3d ago
gonna test it now, sry for taking so long
Sun「無用」
Sun「無用」OP3d ago
same thing, it hangs there, it doesn't do anything
No description
Sun「無用」
Sun「無用」OP3d ago
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["deno"]
output = "../generated/client"
}

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

model Task {
id String @id @default(cuid())
name String
completedAt DateTime? @map("completed_at")

@@map("tasks")
}
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["deno"]
output = "../generated/client"
}

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

model Task {
id String @id @default(cuid())
name String
completedAt DateTime? @map("completed_at")

@@map("tasks")
}
That's all I have in the prisma file deno run -A --allow-scripts --unstable-detect-cjs npm:prisma@latest generate that was the command I ran
Inbestigator
Inbestigator3d ago
--no-engine or whatever the arg is
Sun「無用」
Sun「無用」OP3d ago
prisma says nope
No description
Sun「無用」
Sun「無用」OP3d ago
I'm starting to think that prisma doesn't like me
Sun「無用」
Sun「無用」OP3d ago
wait, it's a miracle, it actually failed now!
No description
toni
tonithis hour
maybe you could find another way 😄
toni
tonithis hour
last time I tried it, i need to comment previewFeatures = ["deno"] . The settings only working with prisma accelerate in this tutorial https://www.prisma.io/docs/orm/prisma-client/deployment/edge/deploy-to-deno-deploy
Deploy to Deno Deploy | Prisma Documentation
Learn how to deploy a TypeScript application to Deno Deploy.
Grant3W
Grant3W2h ago
I had a simlar error to the issue you are having. Try deleteing the prisma directories from your node_modules folder, running npm install and trying again. Also... - Use --unstable-detect-cjs when running your server. - Use engineType = "library" in your Prisma schema. - Use previewFeatures = ["deno"] in your Prisma schema. - When importing your client, use import { type PrismaClient } from "{path-to-generated}/generated/client/index.d.ts";

Did you find this page helpful?