skip to Main Content

I am using NextJs, Typescript, Prisma and MongoDb. Everything works fine when i run "npm run build". But when I am trying to deploy a project on Vercel, I am getting this error:
Type error: Module ‘"@prisma/client"’ has no exported member ‘Product’.

Here is my prisma.schema:

generator client {
  provider = "prisma-client-js"  
}

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

model Product {
  id               String      @id @default(auto()) @map("_id") @db.ObjectId
  category         String
  imageSRC         String
  name             String
  onStock          Int
  price            Int
  quantityPerUnit  String
  type             String
  shortDescription String
  longDescription  String
  createdAt        DateTime    @default(now())
  updatedAt        DateTime    @updatedAt
  CartItem         CartItem[]
  orderItems       OrderItem[]

  @@map("products")
}

And here is a part of my code, where i have an error:

import {  Product } from '@prisma/client'

interface ProductCardProps {
  product: Product;
}


export default function ProductCard({product} : ProductCardProps) {
  const productPrice = (product.price).toLocaleString("ru-RU") + " сум";
  return (
  1. Tried to add this on prisma.schema
output = "../../node_modules/.prisma/client"

2

Answers


  1. if you want to use tables you should npx prisma generate on the terminal

    it command gives you hints for table columns

    Login or Signup to reply.
  2. Add the following to your package.json scripts

    "postinstall": "prisma generate"
    

    You need to tell vercel to generate the types within your schema. In this case, the Product table does not exist as a type until you run prisma generate. You don’t encounter this error locally, because presumably you ran prisma generate on your computer before you ran npm run build, and npm run build was able to find the Product type.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search