ARTICLE AD BOX
I’m trying to add Prisma to an Express + TypeScript project to handle PostgreSQL queries by following the official Prisma docs.
According to the docs, after generating the client I should be able to do:
const prisma = new PrismaClient();However, I’m getting TypeScript errors when doing this.
Prisma schema
generator client { provider = "prisma-client" output = "../src/generated/" prismaSchemaFolder = true } datasource db { provider = "postgresql" }After running prisma generate, I import the client like this:
import { PrismaClient } from "../generated/client"; const prisma = new PrismaClient();Error
Expected 1 arguments, but got 0.ts(2554) class.ts(73, 5): An argument for 'options' was not provided.The Prisma docs don’t mention any mandatory constructor options.
When I try to pass a datasourceUrl explicitly as it is a mentioned optional parameter:
import { PrismaClient } from "../generated/client"; const prisma = new PrismaClient({ datasourceUrl: "postgresql://johndoe:randompassword@localhost:5432/mydb", }); export default prisma;I get another error:
Object literal may only specify known properties, and 'datasourceUrl' does not exist in type Subset<PrismaClientOptions, PrismaClientOptions>.What is the correct way to configure Prisma for an Express + TypeScript + PostgreSQL project when using a generated client?
