Nextjs build: The specified property is not found in the type 'PrismaClient'

I have a NextJS app (TypeScript) using Prisma on Netlify. Recently, I introduced a new model named Trade in the Prisma schema file:

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

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

model Contract {
  id              Int     @id @default(autoincrement())
  contractAddress String  @unique
  baseUri         String
  tokenName       String  @default("")
  verified        Boolean @default(false)
}

model Trade {
  id      Int @id @default(autoincrement())
  tradeId Int @unique
  status  Int
}

I created the migration file and executed the migrations locally and in production successfully, confirming the existence of the new table in both databases.

Although everything works well locally, attempting to deploy to Netlify results in an error shown in the build log:

Type error: Property 'trade' does not exist on type 'PrismaClient<PrismaClientOptions, never, RejectOnNotFound | RejectPerOperation | undefined>'.
12:37:51 PM:   10 |     return res.status(400).send({ message: "No trade ID provided" })
12:37:51 PM:   11 |   try {
12:37:51 PM: > 12 |     const tradeInDatabase = await prisma.trade.findFirst({

The Prisma plugin is integrated into the site, and everything was functioning smoothly with other models until the addition of this new model. Trying to resolve why the Prisma client lacks awareness of the new model in a production environment.

Any assistance would be greatly appreciated!

Answer №1

After some troubleshooting, I found the solution by making adjustments to the build script within package.json

"scripts": {
    "dev": "next dev",
    "build": "prisma generate && next build",
    "start": "next start",
    "lint": "next lint"
  },

By including the prisma generate command in the build process for production, a new prisma client is generated successfully.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to access the result without using subscribe in Angular?

I am facing unexpected behavior with a method in my component: private fetchExternalStyleSheet(outerHTML: string): string[] { let externalStyleSheetText: string; let match: RegExpExecArray; const matchedHrefs = []; while (match = this.hrefReg.exe ...

What is the best way to monitor updates made to a function that utilizes firestore's onSnapShot method?

I am currently working with the following function: public GetExercisePosts(user: User): ExercisePost[] { const exercisePosts = new Array<ExercisePost>(); firebase.firestore().collection('exercise-posts').where('created-by&apo ...

Creating a case-insensitive path for pages in NextJS can be achieved by ensuring that all

I have a file named about.tsx under the pages folder. This means that the path for accessing the page is /about, allowing me to visit it through example.com/about. Strangely, attempting to access the same page via example.com/About results in a 404 error ...

Encountering an issue with Apollo subscriptions in Next.js, where an Observable is being cancelled prematurely with an error message

While working on my Next.js project, I encountered an issue with implementing apollo/graphql subscription. My graphql server is located in an external Next.js service and I have successfully worked with queries and mutations. However, when trying to use th ...

What is the best way to send multiple parameters to @Directives or @Components in Angular using TypeScript?

I am facing some confusion after creating @Directive as SelectableDirective. Specifically, I am unclear on how to pass multiple values to the custom directive. Despite my extensive search efforts, I have been unable to find a suitable solution using Angula ...

What steps should I take to create secure and exclusive routes in the upcoming version 13 of Next

Recently, I've started working with next 13 and have successfully created pages for my app such as about, contact, and dashboard. In the dashboard section, I require authentication (auth). Users with a token can access the dashboard while others will ...

Error: Module not found - The package path "." is not exported from the specified package. As a result, Firebase will not update in your Next.js

I have been developing a Next.js application that retrieves data from a Firebase collection. During the process of connecting to the Firebase database, I have come across the following error: Failed to compile. Module not found This error seems to be ori ...

Tips for stopping </p> from breaking the line

<p>Available: </p><p style={{color:'green'}}>{props.active_count}</p><p>Unavailable: </p><p style={{color:'red'}}>{props.inactive_count}</p> I want the output to display as two separate l ...

Typescript's way of mocking fetch for testing purposes

I have a query regarding the following code snippet: import useCountry from './useCountry'; import { renderHook } from '@testing-library/react-hooks'; import { enableFetchMocks } from 'jest-fetch-mock'; enableFetchMocks(); i ...

What is causing unexpected behavior when one service calls another service?

Let's say I make a call to a service that returns an observable, and if it doesn't encounter any errors, then another service should be called which also returns an observable. What I tried doing is calling both services separately, one after th ...

Display the chosen HTML template in real-time

Recently, I started using Angular 2 and encountered an issue that I need help with. 1] I have created 2-3 templates for emails and SMS that will display predefined data. 2] I have also designed a screen with a dropdown menu containing options like email ...

Is there a feature similar to Nuxt.js' auto-register in Next.js?

My Journey as a Beginner Being a beginner in the tech world, specifically in full-stack development (although I'm about 8 years behind), I find myself grappling with the decision of what to focus on learning. Vue and Nuxt.js are fantastic technologi ...

Is it possible to use a TypeScript Angular (click) event with an object property as the value?

Seeking assistance in creating a dynamic error card featuring various error messages along with a retry button. Below is a snippet from my TypeScript object: errorCard: any = []; if(error) { this.errorCard.errorMessage = "Oops, please try again"; ...

Using Angular material to display a list of items inside a <mat-cell> element for searching

Can I use *ngFor inside a <mat-cell> in Angular? I want to add a new column in my Material table and keep it hidden, using it only for filtering purposes... My current table setup looks like this: <ng-container matColumnDef="email"> < ...

Having trouble with implementing custom checkboxes in a d3 legend?

My attempt at creating checkboxes in d3 has hit a snag. Upon mouse click, the intention is for them to be filled with an "x". Strangely, using d3.select() inside the click-function doesn't seem to work as expected, although adding the letter U for the ...

Display a complete inventory of installed typings using the tsd command

How can I display a list of all installed tsd typings in the terminal? Perhaps using the following command: $ tsd list ...

Encountering an error message of "BrowserAuthError:uninitialized_public_client_application" while attempting to use SSO with MSAL in a React and Next.js

I am currently developing a React application using Next.js 14 and the App router. I am attempting to implement single sign-on (SSO) using Azure Msal. In my project, I have created a Msal.ts file which contains the MSAL configuration that I am utilizing i ...

A unique Angular decorator is created to seamlessly integrate a new component within an existing component

I'm currently experimenting with creating a decorator in Angular that will display a spinner on top of the main component. Essentially, my main component is making API requests and I want to overlay the decorator on top of the method. This is how I ...

The close button in Angular 4 is unresponsive until the data finishes loading in the pop-up or table

Having trouble with the Close button in Angular 4 popup/table The Pop Up is not closing after clicking anywhere on the screen. I have added backdrop functionality so that the pop-up closes only when the user clicks on the close icon. However, the close i ...

The right structure of folders and dynamic routing in Next.js

I have a Link that passes a href in my code snippet: { name: "Action", cell: (row) => ( <div className="flex items-center space-x-5"> <Link href={`/members/${row.id}/edit`}>Edit</Link&g ...