#website fails to compile due to type errors on vercel but compiles fine on my system

3 messages · Page 1 of 1 (latest)

meager flower
#

Given this schema: https://github.com/tonijarjour/website/blob/main/prisma/schema.prisma

model Like {
  id      Int     @id @default(autoincrement())
  addr    String
  route   String
  @@unique([route, addr])
}

Code where it happens: https://github.com/tonijarjour/website/blob/main/pages/api/sendlike/[route].ts:

    const prevLike = await prisma.like.findUnique({
      where: {
        route_addr: {
          route: route as string,
          addr: clientIp as string,
        },
      },
    });

Error:

Type error: Type '{ route_addr: { route: string; addr: string; }; }' is not assignable to type 'LikeWhereUniqueInput'.
Object literal may only specify known properties, and 'route_addr' does not exist in type 'LikeWhereUniqueInput'.

This error happens on Vercel. It builds fine on my system.

#

ok i figure it out, change package.json like this:
"build": "prisma generate && next build",

glad orchid
#

It's better to add a postinstall script in your package.json

"scripts": {
    "build": "next build",
    "postinstall": "prisma generate",
    ...
  },